我收到以下错误:“未定义不是updateRelatedEntityInCollection updateRelatedEntityInCollection中的一个函数
当使用微风叠加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");
}当我查询控制器是否有代理时(没有过滤器,只需要
return context.Agencies我要拿回下面的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‘type’结果(无论是用toType还是如果我设置元数据映射),都会引发此错误。relatedEntity for updateRelatedEntityInCollection是一个填充的Staff对象,没有简单的道具(没有EntityAspect),inverseProperty associationName是Staff_Agency。
我想无论出于什么原因,Staff对象在从服务器返回后不会得到“轻松化”。
发布于 2014-05-26 23:34:46
动态代理是问题所在。您需要关闭它们,或者使用Breeze的EFContextProvider,它可以正确地配置事物。
微风通过"$type“属性识别实体,当使用代理时,该属性将变得不可识别。
https://stackoverflow.com/questions/23861496
复制相似问题