IdentityServer / IdentityServer3.EntityFramework

EntityFramework persistence layer for IdentityServer3
Apache License 2.0
68 stars 97 forks source link

Subclassing DbContexts and adding migrations throws #129

Open prochnowc opened 7 years ago

prochnowc commented 7 years ago

We have a problem adding custom migrations to the DbContexts.

Because of the ConfigureChildCollections() call in the constructor of BaseDbContext we are not able to add our migrations. The overridden ConfigureChildeCollection methods retrieves EntitySets. When migrations are pending this horribly fails. To maken it even more worse: DbContext.Set<> is also virtual. It is considered bad practice to call virtual methods in constructors and in this case prevents running migrations.

brockallen commented 7 years ago

In that case, I'd suggest forking and doing what you need all in your own copy of the code. I don't think EF6 and its migrations were designed for library developers.

prochnowc commented 7 years ago

Your statement about migrations in libraries is totally valid. Thats why we created our own migrations for DbContexts from IdentityServer3.EntityFramework in our application. The problem is that the design of the IDSRV DbContexts is broken. Migrator instantiates the DbContext to build the model. And because you fetch EntitySets in the ctor this breaks. If you dont want to fix this, maybe you will accept PRs for this issue?

brockallen commented 7 years ago

Sure, as long as it's not a major breaking change. If it needs to be, then we'll push it to 3.0 release