-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type consistraints in IdentityDbContext as an inerface #12242
Comments
@ajcvickers Is this even possible with EF? |
@blowdart Kind of, but it's not as clean as it could be and it has limitations. But regardless, this would be a massive breaking change to the Identity model, which I don't think we can justify at this time. |
Alight, backlog and we'll think about it for v5 |
Could the following interfaces be introduced and referenced by the appropriate classes? User related interfaces (would be implemented by IdentityUser, IdentityUserClaim, IdentityUserLogin, IdentityUserToken):
Role related interfaces (would be implemented by IdentityRole, IdentityRoleClaim, IdentityUserRole):
|
This could then be expanded on by adding interfaces with Navigation Properties as shown here. User related "nav" interfaces:
Role related "nav" interfaces:
Note: I have used Nav as a suffix just to demonstrate, but I'm sure something better could be used. |
This would also then allow for (provided IDbContext was created also which has been requested here):
|
@blowdart After looking through much of the code for Identity and Ef core, I can see the complications. Thanks for looking into this. I hope you can come up with a good solution in V5 |
Reopening, and leaving open because otherwise we won't ever triage this when we backlog groom |
@blowdart Sure thing. Thanks again for taking a serious look at my request! |
I'm experiencing a similar issue. We already have a base class we need to implement on the class which would be our IdentityUser. |
yes please. |
@blowdart , @ajcvickers - Would you consider a contribution from the community on this one? I am running into the same issue as others have stated here. I have forked the aspnetcore repo and made the appropriate modifications to extract an All tests are currently passing. I only worked on extracting an interface for |
@blowdart we should chat about his next triage since there's a PR open that i need to make a call on |
This is all too big a breaking change I'm afraid, sorry @StevenRasmussen |
I am looking to implement my own base class for the identity tables. The issue is the IdentityDbContext<> type constraints only allow for concrete types. This requires any custom class to extend those base classes. For example when using a custom user you would need to define your user class like below
public ApplicationUser : IdentityUser{}
Since you can only extend one class, it makes my goal impossible.
I would suggest using interfaces for your type constraints to decouple the base identity tables from the db context allowing me to implement the interface and extend my own base class. Instead of the above example I would define my custom user class like below
public ApplicationUser : CustomBasClass, IIdentityUser{}
Now the base table is decoupled and I can extend my own base class if needed.
You can still directly extend the identity base classes, but this way you can do both
The text was updated successfully, but these errors were encountered: