Breeze “不动产”;“未定义”不是一个函数;具有1.14.12堆栈(EF6)

Breeze “不动产”;“未定义”不是一个函数;具有1.14.12堆栈(EF6),breeze,entity-framework-6,asp.net-web-api2,Breeze,Entity Framework 6,Asp.net Web Api2,我收到以下错误: “undefined不是UpdateRelateIdentityInCollection(localhost:3091/scripts/breeze.debug.js:14542:40)上的函数” 当使用breeze stack 1.14.12和EF 6.1/WebApi2时 我在服务器端定义了以下实体/映射: public partial class Agency { public Agency() { this.Programs = new

我收到以下错误: “undefined不是UpdateRelateIdentityInCollection(localhost:3091/scripts/breeze.debug.js:14542:40)上的函数”

当使用breeze stack 1.14.12和EF 6.1/WebApi2时

我在服务器端定义了以下实体/映射:

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");
}
我将返回以下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"}]
只要Breeze“键入”结果(使用toType,或者如果我设置了元数据映射),就会引发此错误。 UpdateRateIdentityInCollection的relatedEntity是一个填充的Staff对象,没有breeze道具(没有EntityAspect),inverseProperty associationName是Staff\u Agency


我想无论出于什么原因,Staff对象从服务器返回后都没有得到“breezized”。

动态代理是问题所在。您需要关闭它们,或者使用Breeze,它可以正确配置


Breeze通过“$type”属性识别实体,当使用代理时,该属性将无法识别。

感谢您的回复。我正在使用EFContextProvider,公开元数据WebApi终结点,并且可以在fiddler中确认Breeze正在查询它。此外,$type属性将在Json结果中返回(我帖子中的JSON显示了查询结果中的属性)。我是否遗漏了什么?啊,我在对DataContext的OnModelCreating覆盖中遗漏了
Configuration.ProxyCreationEnabled=false;Configuration.LazyLoadingEnabled=false;
。谢谢!
[{"$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"}]