How to use ASP.NET Identity 3.0 without Entity Framework [closed] How to use ASP.NET Identity 3.0 without Entity Framework [closed] asp.net asp.net

How to use ASP.NET Identity 3.0 without Entity Framework [closed]


I have implemented it in my project, the main things you have to implement is UserStore and RoleStore

my SiteUser and SiteRole classes do not inherit from anything

the main thing is to add your own services before letting asp.net identity add its own services

services.TryAdd(ServiceDescriptor.Scoped<IUserStore<SiteUser>, UserStore<SiteUser>>());services.TryAdd(ServiceDescriptor.Scoped<IUserPasswordStore<SiteUser>, UserStore<SiteUser>>());services.TryAdd(ServiceDescriptor.Scoped<IUserEmailStore<SiteUser>, UserStore<SiteUser>>());services.TryAdd(ServiceDescriptor.Scoped<IUserLoginStore<SiteUser>, UserStore<SiteUser>>());services.TryAdd(ServiceDescriptor.Scoped<IUserRoleStore<SiteUser>, UserStore<SiteUser>>());services.TryAdd(ServiceDescriptor.Scoped<IUserClaimStore<SiteUser>, UserStore<SiteUser>>());services.TryAdd(ServiceDescriptor.Scoped<IUserPhoneNumberStore<SiteUser>, UserStore<SiteUser>>());services.TryAdd(ServiceDescriptor.Scoped<IUserLockoutStore<SiteUser>, UserStore<SiteUser>>());services.TryAdd(ServiceDescriptor.Scoped<IUserTwoFactorStore<SiteUser>, UserStore<SiteUser>>());services.TryAdd(ServiceDescriptor.Scoped<IRoleStore<SiteRole>, RoleStore<SiteRole>>());

some of the same interfsaces will be registered here but it will use yours if they are registered first

services.AddIdentity<SiteUser, SiteRole>();


Are there any example which does not use EntityFramework and where ApplicationUser class is not derived from Microsoft.AspNet.Identity.EntityFramework.IdentityUser?

Since ASP.NET Identity 3 is part of the .NET Framework 5, which is still unreleased, my guess is you won't find any examples.

In ASP.NET Identity 2.x it was needed to implement IUser interface. It seems there is not such interface now - so we're not sure how to define "User" class correctly.There is almost no documentation on this subject.

Again, the lack of docs is probably due to the unreleased nature of the software. However just looking at the source code, it seems as though the ApplicationUser can derive from any POCO object -- without the need to implement an IUser<TKey> interface.

As far as configuring services, have a look at IdentityServiceCollectionExtensions and IdentityEntityFrameworkBuilderExtensions. It seems as if the first is in identity core as a means of providing a context within which to register services for application identity, whereas the second is an entityframework-specific implementation using that context.

The solution for implementing something that uses ASP.NET Identity 3 but not EF seems like it would just be a matter of providing different implementations for the identity service interfaces and then wiring up those dependencies during app configuration. You can use the base EntityFramework implementation as a guide for how to DIY. But caveat emptor, identity 3 could change again before final release, so anything you build against identity 3 now is subject to change.