I have a polymorphic collection on one entity type that contains a collection of objects that are the child types of it. the child types are all stored in different tables in the db.
I need to map this relationship in the fluent API so I can manage the cascades. Here's a sample of the entity structure I have ...
[Table("Reports", "Reporting")]
class Report
{
[Key]
public int Id { get; set; }
public virtual ICollection<Entry> Entries { get; set; }
}
abstract class Entry
{
[Key]
public int Id { get; set; }
public virtual ICollection<Report> Reports { get; set; }
}
[Table("InvoiceEntries", "Reporting")]
class InvoiceEntry : Entry
{
public ICollection<Invoice> Invoices { get; set; }
}
... <other types> like InvoiceEntry each mapped to their own tables ...
In my model configuration I have ...
builder.Ignore<Entry>();
Update
As mentioned in the comments, there's a great answer here on polymorphic relationships ...
... My scenario is the "Table Per Concrete Type" one with a Many to Many Relationship as the polymorphic one.
Whilst that description is great it doesn't seem to cover this scenario