Search for existing suggestions

Provide access to ModelBuilder for Database First

Our database structure is set up in such a way that all tables contain soft-deleted columns and most contain an owner account key column.

Both of these provide a level of filtering we would like to let Entity Framework take care of for us at a global level, instead of always writing "&& t.Deleted == false && t.Owner == LoggedInOwnerKey" on our linq join/where clauses.

This is currently possible with Code First, when you use the DbModelBuilder during the DbContext.OnModelCreating() but that method is not available when using EDMX strategy.

All we are doing with the DbModelBuilder is adding System.Data.Entity.ModelConfiguration.Conventions.IConventions to the DbModelBuilder.Conventions collection.

Either of the two solutions would fix this issue:
1) Provide DbModelBuilder or the Conventions collection (perhaps by something other than OnModelBuilding) when using EDMXs so that filters can be configured regardless of code generation strategy. Using filtering by DbSet is not an option because it does not respect the filters for navigational property access.

2) Provide a way to choose the fluent Code-First style code generation when using EDMXs, which is set up to call OnModelCreating().

6 votes
Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

Kyle H shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

0 comments

Sign in
(thinking…)
Sign in with: facebook google
Signed in as (Sign out)
Submitting...

Feedback and Knowledge Base