Does new ASP.NET MVC identity framework work without Entity Framework and SQL Server? entity-framework owin sql-server


I am new to ASP.NET MVC 5 and so I am trying to use it as much as possible to learn it by practice.

So I am thinking of using the new OWIN implementation of ASP.NET MVC to implement the authentication and authorization of my project. That said, I am building the project in a way that it can work with various types of databases.

So far I have used generic ADO.NET elements (e.g. DbDataReader etc) and I have refused to use any ORM. So I am wondering if I can go ahead with using the new identity system of ASP.NET or will I be bound to Entity Framework and SQL Server if I do so?

3/26/2014 6:06:59 AM

Accepted Answer

Not that simple. Not that hard either.

You'll have to write your custom implementation of:

  1. IUserStore<TUser>
  2. IUserPasswordStore<TUser>
  3. IUserTwoFactorStore<TUser>
  4. IUserClaimStore<TUser>
  5. IRoleStore<TRole>
  6. IUserSecurityStampStore<TUser, string>
  7. IUserRoleStore<TUser, string>
  8. UserManager<TUser>

Then create your own user implementation, from IUser<TKey>, like:

public class MyUser : IUser<string>
    public string Id { get; set; }
    public string UserName { get; set; }

Finally, from NuGet, remove AspNet.Identity.EntityFramework, which will remove EntityFramework too if you're not using it elsewhere.

Wherever your code breaks, rewrite it to use your custom implementations.


Create a MyUserRepository which implements items from 1 to 7.

Than, create a MyUserManager which implements item 8.

It will be damn easy to wire that up in place of default AspNet.Identity.EntityFramework classes.

2/18/2016 3:51:57 PM

Popular Answer

To piggy-back on what ALMMa said, when I was working on my own custom implementation, I found this article to be invaluable:

Overview of Custom Storage Providers for ASP.NET Identity

It details no only what Interfaces need to be implemented, but goes into detail on how to implement them and gives code sample references to an actual MySQL implementation.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow