EFDesigner
EFDesigner copied to clipboard
ASP.NET Core Identity support [Feature Request]
To support custom ASP.NET Core Identity scenario with EFDesigner some manual work has to be done.
- Implement 7 custom entities which inherit types from
Microsoft.AspNetCore.Identity
namespace:
-
IdentityUser
-
IdentityRole
-
IdentityUserClaim<TKey>
-
IdentityUserRole<TKey>
-
IdentityRoleClaim<TKey>
-
IdentityUserLogin<TKey>
-
IdentityUserToken<TKey>
Note: TKey
type parameter defaults to string
type.
-
Implement custom part of EFDesigner-generated DbContext class to define 7 respective DbSets and create model using partial
OnModelCreatedImpl()
method. -
Somehow inherit
IdentityDbContext<TUser,TRole,TKey,TUserClaim,TUserRole,TUserLogin,TRoleClaim,TUserToken>
type fromMicrosoft.AspNetCore.Identity.EntityFrameworkCore
namespace instead of defaultDbContext
fromMicrosoft.EntityFrameworkCore
.
Note: IdentityDbContext<>
in turn inherits DbContext
.
First 2 points are manual work because EFDesigner lacks:
- support for generated entity to inherit any type (not just other entity type defined on a diagram);
- support for
string
type to be used as identity (actually not a strong requirement becauseInt64
may be used forTKey
type parameter).
This is safe to implement. Not a big problem actually.
But 3rd point needs to copy EFCoreDesigner.ttinclude
template to a project directory and remove the : Microsoft.EntityFrameworkCore.DbContext
text from it. Then in file from point 2 add something like : Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext<MyUser, MyRole, string/*TKey*/, MyUserClaim, MyUserRole, MyUserLogin, MyRoleClaim, MyUserToken>
.
This introduces a problem to EFDesigner extension updates management. So it would be great to implement string property in EFDesigner for setting custom base class for DbContext (like ConnectionString
). Truth to be told it's the only crusial part of all this request :)