-
Notifications
You must be signed in to change notification settings - Fork 60
Inherit IdentityDbContext or any other custom DbContext #134
Comments
That's a feature that's on the drawing board right now. It turns out to be ... complicated. It's quite easy to simply change the inheritance chain for the generated That means a few restrictions and validations have to be in place that turn out to be nontrivial. There is a branch that I started and haven't gotten back to in quite a while, but do plan to return to after the 2.0 release. That's going to happen in the pretty near future. The person that put in the enhancement request all those many months ago also implemented an example project that points out one way the output could look. I still have that code and plan to re-review it when I get back to that enhancement. (Or, of course, someone else can pick up on it and help carry it forward [hint, hint] since it is open source!) That being said, for a short-term, down-and-dirty approach you can always copy the appropriate Hope that answers the question. :-) -- Michael |
I managed to make this work according to your instructions. Things I did:
After this, other entities in schema are simply bound to Account, and all is OK. If there was the possibility to set base DbContext and possibility to set base class for entities in the free form (like for custom attributes), out of the list of already created entities in the designer, need for changing templates would not exist. But, I believe that releasing mentioned constraints would create a mess on some other side. |
In 2.0 we'll have the ability to change the base class of the context to something other than DbContext, but full IdentityDbContext support won't yet be there in the way I want it to be. A step forward, though! :-) |
Hi, just a short question. Is it now possible or will be supported to somehow set custom DbContext to be inherited instead of DbContext class itself on code generation?
Example: since dbcontext file is autogenerated it will be rewritten each time something is changed in designer, and example where mentioned feature is needed is when using Microsoft Identity. In order to use Identity framework, application db context should be inherited from IdentityDbContext which itself inherits DbContext.
Thanks.
The text was updated successfully, but these errors were encountered: