Q:

Breeze getProperty "undefined is not a function" with 1.14.12 stack (EF6)

I am receiving the following error:
"undefined is not a function at updateRelatedEntityInCollection (localhost:3091/scripts/breeze.debug.js:14542:40"
when using the breeze stack 1.14.12 with EF 6.1 / WebApi2.
I have the following entities / maps defined server-side:
public partial class Agency
{
    public Agency()
    {
        this.Programs = new HashSet<AgencyProgram>();
        this.Locations = new HashSet<Location>();
        this.Participants = new HashSet<Participant>();
        this.StaffMembers = new HashSet<Staff>();
    }

    public int Id { get; set; }
    public string Name { get; set; }

    public virtual ICollection<AgencyProgram> Programs { get; set; }
    public virtual ICollection<Location> Locations { get; set; }
    public virtual ICollection<Participant> Participants { get; set; }
    public virtual ICollection<Staff> StaffMembers { get; set; }
}

public partial class Staff
{
    public Staff()
    {
        this.CareerClubs = new HashSet<CareerClub>();
        this.ClassFacilitation = new HashSet<ClassFacilitator>();
    }

    public int AgencyId { get; set; }
    public int Id { get; set; }
    public string Name { get; set; }

    public virtual Agency Agency { get; set; }
    public virtual ICollection<CareerClub> CareerClubs { get; set; }
    public virtual ICollection<ClassFacilitator> ClassFacilitation { get; set; }
}

public class StaffMap : EntityTypeConfiguration<Staff>
{
    public StaffMap()
    {
        // Primary Key
        this.HasKey(t => t.Id);

        // Properties
        this.Property(t => t.Name)
            .IsRequired()
            .HasMaxLength(50);

        // Table & Column Mappings
        this.ToTable("Staff");
        this.Property(t => t.AgencyId).HasColumnName("AgencyId");
        this.Property(t => t.Id).HasColumnName("Id");
        this.Property(t => t.Name).HasColumnName("Name");
    }
}

public class AgencyMap : EntityTypeConfiguration<Agency>
{
    public AgencyMap()
    {
        // Primary Key
        this.HasKey(t => t.Id);

        // Properties
        this.Property(t => t.Name)
            .IsRequired()
            .HasMaxLength(50);

        // Table & Column Mappings
        this.ToTable("Agency");
        this.Property(t => t.Id).HasColumnName("Id");
        this.Property(t => t.Name).HasColumnName("Name");
}

When I query the controller for Agencies (no filters, just a
return context.Agencies

I am getting back the following Json
[{"$id":"1","$type":"System.Data.Entity.DynamicProxies.Agency_09777AD4C70881ED42DD78FB209FCD42C4995B1603097BBFD98C061405E71961, EntityFrameworkDynamicProxies-Model.Persistence","Locations":[],"Participants":[],"Programs":[],"StaffMembers":[{"$id":"2","$type":"System.Data.Entity.DynamicProxies.Staff_B3294F308AC9ED853C9E99FE2B1D765F9433E16FF56372757A43E397DECA38C7, EntityFrameworkDynamicProxies-Model.Persistence","Agency":{"$ref":"1"},"CareerClubs":[],"ClassFacilitation":[],"AgencyId":4,"Id":5,"Name":"Samuel Gonzalez"}],"Id":4,"Name":"Test Agency\r\n"}]

Anytime Breeze 'types' the results (either with toType, or if I set metadata mappings) this error is thrown.
The relatedEntity for the updateRelatedEntityInCollection is a populated Staff object without breeze props (no EntityAspect) and the inverseProperty associationName is Staff_Agency.
I guess for whatever reason the Staff object is not getting 'breezified' after coming back from the server.

A:

The dynamic proxies are the problem.  You'll need to turn them off, or use Breeze's EFContextProvider, which configures things correctly.
Breeze recognizes the entities by the "$type" property, which becomes unrecognizable when proxies are used. 

