Answer the question
In order to leave comments, you need to log in
fluent api. How to disable TPH? Why is EF trying to find a field that doesn't exist in the entity?
Help. How to disable TPH, or rather, so that EF does not require the creation of the Discriminator field? And can you explain why FE is looking for a field (in my case it is supplier_Id) that does not exist in the entity?
Essence
public class Supplier
{
public int Id { get; set; }
public int companyId { get; set; }
public virtual Company Company { get; set; }
}
public class SupplierConfiguration : EntityTypeConfiguration<Supplier>
{
public SupplierConfiguration()
{
ToTable("suppliers");
HasKey<int>(s => s.Id);
Property(s => s.companyId).HasColumnName("companyid").IsRequired();
HasRequired(s => s.Company).WithMany().HasForeignKey(s => s.companyId);
}
}
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
modelBuilder.Configurations.Add(new SupplierConfiguration());
modelBuilder.Configurations.Add(new CompanyConfiguration());
modelBuilder.Configurations.Add(new CountryConfiguration());
base.OnModelCreating(modelBuilder);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question