Azure – Details of customizing ASP.NET Identity (OWIN) use of Entity Framework

asp.net-identityazureazure-table-storageentity-frameworkowin

This blog:

http://blogs.msdn.com/b/webdev/archive/2013/06/27/introducing-asp-net-identity-membership-system-for-asp-net-applications.aspx

about the ASP.NET identity provider states:

Persistence control

By default the ASP.NET Identity system will store all the user information in a database. ASP.NET Identity uses Entity Framework Code First to implement all of its persistence mechanism.

If your application requirements are that this information might be stored in a different storage mechanism such as SharePoint, Azure Table Service, No Sql databases etc. it is now possible to plug in different storage providers.

But how can one use the Azure table service with this? My research shows that you cannot use the entity framework with the table service, so I think you'd have to replace the code that uses the entity framework entirely, but I'm not sure.

Related question: I'm new to EF in general. How can we customize how data is stored (even in SQL server)? I've found two examples that show adding extra fields to the user table:

http://www.asp.net/mvc/tutorials/mvc-5/create-an-aspnet-mvc-5-app-with-facebook-and-google-oauth2-and-openid-sign-on

http://www.asp.net/web-api/overview/security/external-authentication-services

But it's not clear to me what's going on exactly. I think that it's using Entity Framework code first, but I see very little documentation about how to customize how data is being stored by EF for this. For example, can I rename entities? Can I define what the database will be called?

Thanks…

-Ben

Best Answer

  • Asp.Net Identity has default implementation of storage using EntityFramework.

  • Microsoft.AspNet.Identity.Core has a list of interfaces, that need to be implemented to store the data where and how you want. These interfaces provide minimum required members and methods.

  • IdentityManager is the main entry point where you can pass your custom store interface implementation.

IdentityManager(Microsoft.AspNet.Identity.IIdentityStore)

Look this customization for framework (not relating to store/storage, it will guide you further)

Implementing User Confirmation and Password Reset with One ASP.NET Identity