You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default the derived type expects a column for the primary key with the same name as the base type. Is it possible to change the column name only for the derived type table?
publicclassObjectEntity{publicintId{get;set;}publicDateTimeDateCreated{get;set;}}publicclassMyObjectEntity:ObjectEntity{publicintObjectId{get=>Id;set=>Id=value;}publicGuid?Guid{get;set;}}builder.Entity<ObjectEntity>(e =>{e.ToTable("Objects","dbo");e.Property(x =>x.Id).HasColumnType("int").HasColumnName("Id").UseIdentityColumn();e.Property(x =>x.DateCreated).HasColumnType("datetime").HasColumnName("DateCreated").IsRequired(true).HasDefaultValueSql("GETDATE()").ValueGeneratedOnAdd();e.HasKey(x =>x.Id);});builder.Entity<MyObjectEntity>(e =>{e.ToTable("MyObjects","dbo");// This changes it for both tables not only for `dbo.MyObjects`e.Property(x =>x.Id).HasColumnName("ObjectId");// This expects both columns (Id, ObjectId)//e.Property(x => x.ObjectId).HasColumnType("int").HasColumnName("ObjectId");e.Property(x =>x.Guid).HasColumnType("uniqueidentifier").HasColumnName("Guid").IsRequired(false);e.HasBaseType<ObjectEntity>();});
By default the derived type expects a column for the primary key with the same name as the base type. Is it possible to change the column name only for the derived type table?
Actual tables:
dbo.Objects -> (ObjectId, DateCreated)
dbo.MyObjects -> (ObjectId, Guid)
Expected tables:
dbo.Objects -> (Id, DateCreated)
dbo.MyObjects -> (ObjectId, Guid)
The text was updated successfully, but these errors were encountered: