C# 方法System.Data.Entity.ModelConfiguration.EntityTypeConfiguration的类型参数<;Proyect.Models.Entity>;。有许多<;t目标实体>;
我提出了一个很多人都知道的问题,但这困扰着我,我需要你的帮助。也许很简单…但有时其他人的眼睛可以看到我们看不到的东西 我有这个方法:C# 方法System.Data.Entity.ModelConfiguration.EntityTypeConfiguration的类型参数<;Proyect.Models.Entity>;。有许多<;t目标实体>;,c#,entity-framework,linq,entity-framework-5,C#,Entity Framework,Linq,Entity Framework 5,我提出了一个很多人都知道的问题,但这困扰着我,我需要你的帮助。也许很简单…但有时其他人的眼睛可以看到我们看不到的东西 我有这个方法: protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity<ValorAtributoProducto
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ValorAtributoProducto>()
.HasMany(i => i.AtributoProducto)
.WithRequired().WillCascadeOnDelete(true);
}
模型创建时受保护的覆盖无效(DbModelBuilder modelBuilder)
{
基于模型创建(modelBuilder);
modelBuilder.Entity()
.HasMany(i=>i.AtributoProducto)
.WithRequired().WillCascadeOnDelete(true);
}
这是完全错误:
System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Proyect.Models.ValorAtributoProducto>.HasMany<TTargetEntity>(System.Linq.Expressions.Expression<System.Func<Proyect.Models.ValorAtributoProducto,System.Collections.Generic.ICollection<TTargetEntity>) cannot be inferred from the usage. Try specifying the type arguments explicitly.
System.Data.Entity.ModelConfiguration.EntityTypeConfiguration.HasMany(System.Linq.Expressions.Expression要使用HasMany属性需要实现ICollecon,否则没有“多”,只有“一”
我真的认为你应该用HasRequired来代替