Problem: We have three tables that are inherited as follows
public class BaseEntity : IBaseEntity
{
public int Id { get; set; }
public DateTime? Created { get; set; }
public int? CreatedByUserId { get; set; }
[ForeignKey("CreatedByUserId")]
public User CreatedByUser { get; set; }
public DateTime? Modified { get; set; }
public int? ModifiedByUserId { get; set; }
[ForeignKey("ModifiedByUserId")]
public User ModifiedByUser { get; set; }
}
[Table("User", Schema = "AAA")]
public class User : BaseEntity
{
public string FirstName { get; set; }
public string LastName { get; set; }
[NotMapped]
public string FullName
{
get { return $"{FirstName} {LastName}"; }
}
public string UserName { get; set; }
public string PasswordHash { get; set; }
public bool Active { get; set; }
public bool IsBlock { get; set; }
}
[Table("UserBase", Schema = "AAA")]
public class UserBase:User
{
public string CityName { get; set; }
}
Add-Migration ef1
I want to run using .NET Core 3.1. This is the error:
The entity type 'UserBase' cannot be mapped to a table because it is derived from 'User'. Only base entity types can be mapped to a table.