I have below model structure in EF core Code first approach.
public abstract class BaseModel
{
[Key]
public string Id { get; set; }
public DateTime LastUpdatedDate { get; set; }
}
public class Company :BaseModel
{
public string Name { get; set; }
public string Address { get; set; }
}
public class CompanyLog :Company
{
public string LogId { get; set; }
public DateTime LogDate { get; set; }
}
and DB Context is
public class MyDbContext : DbContext
{
public DbSet<Company> Company { get; set; }
public DbSet<CompanyLog> CompanyLog { get; set; }
}
But after DB migration, CompanyLog table is getting created with only its own properties, but not with base table properties. How can I acheive this? After the db migration, database table structure expectation is
CREATE TABLE dbo."Company"
(
Id text NOT NULL,
LastUpdatedDate TimeStamp,
Name text,
Address text,
)
CREATE TABLE dbo."CompanyLog"
(
Id text NOT NULL,
LastUpdatedDate TimeStamp,
Name text,
Address text,
LogId text NULL,
LogDate TimeStamp,
)