Given the following code example, how do you implement this in entity framework core where you do not want a table created for the base class but you do for the derived class and the primary key is defined in the base class?
public class JobBase
{
public JobBase() { }
public Guid JobId { get; set; } = Guid.NewGuid();
public string Title { get; set; }
}
public class Job : JobBase
{
public Job() { }
public String AdditionalInformation { get; set; }
}
And here is what I have in my DBContext class:
public DbSet<Job> Jobs { get; set; }
var job = mb.Entity<Job>();
job.HasKey(aa => aa.JobId);
job.Property(aa => aa.JobId).HasColumnName("JobId");
I currently get the following error when trying to add-migration:
A key cannot be configured on 'Job' because it is a derived type. The key must be configured on the root type 'JobBase'. If you did not intend for 'JobBase' to be included in the model, ensure that it is not referenced by a DbSet property on your context, referenced in a configuration call to ModelBuilder, or referenced from a navigation on a type that is included in the model.
The only part of the error message I am doing is JobBase is referenced from a navigation on a type that is included in the model but doing that is the whole reason i implemented this relationship in the first place so i can't just remove that navigation.