I have the following mappings in the database:
public abstract class ProductBase
{
public string ID { get; set; }
public string Type { get; set; }
// Base Properties go here
}
public abstract class PermissionBase
{
public string ProductID { get; set; }
}
public class Product : ProductBase { }
public class Addon : ProductBase { }
public class ProductPermission : PermissionBase
{
[ForeignKey("ProductID")]
public virtual Product { get; set; }
}
public class AddonPermission : PermissionBase
{
[ForeignKey("ProductID")]
public virtual Addon { get; set; }
}
In the EF Core Configuration I've set up the following configuration for Product:
builder.Entity<ProductBase>()
.HasDiscriminator<string>("Type")
.HasValue<Product>("Product")
.HasValue<Addon>("Addon")
I need to use the Discriminator value of Product in the Permission table hierarchy in order to separate the different models. Can anybody suggest a way forward?