All of my models have a dynamic property called RelatedItems. I want to dynamically ignore these properties for all entity types.
Thus I created a base DatabaseContext to centralize this convention.
public abstract DatabaseContext : DbContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
var allEntities = modelBuilder.Model.GetEntityTypes();
foreach (var entity in allEntities)
{
entity.Ignore("RelatedItems");
}
}
}
But this gives me this error:
DatabaseContext.cs(23,24): error CS1061: 'IMutableEntityType' does not contain a
definition for 'Ignore' and no accessible extension method 'Ignore' accepting a first
argument of type 'IMutableEntityType' could be found
How can I ignore a property on all of my models?