Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 679
BenjiFB Avatar asked Oct 04 '13 12:10

BenjiFB


People also ask

What is identity in Entity Framework?

ASP.NET Core Identity provides a framework for managing and storing user accounts in ASP.NET Core apps. Identity is added to your project when Individual User Accounts is selected as the authentication mechanism. By default, Identity makes use of an Entity Framework (EF) Core data model.

What is ASP.NET identity framework?

ASP.NET Core Identity: Is an API that supports user interface (UI) login functionality. Manages users, passwords, profile data, roles, claims, tokens, email confirmation, and more.

What is Entity Framework and why we use it?

The Entity Framework enables developers to work with data in the form of domain-specific objects and properties, such as customers and customer addresses, without having to concern themselves with the underlying database tables and columns where this data is stored.


3 Answers

  • 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

like image 157
jd4u Avatar answered Nov 15 '22 12:11

jd4u


I answered a similar question here with a sample azure table storage implementation which should be usable against 1.0.0 RTM bits

Azure Table Storage User Store

like image 28
Hao Kung Avatar answered Nov 15 '22 12:11

Hao Kung


This ought to provide most, if not all, of the details the OP asks about: How To: Use Azure Table Storage as an OAuth Identity Store with Web API 2

It looks like K. Scott Allen has started a series of blog posts headed in this general directions (MongoDB vs. Azure Tables) as well.

like image 38
Jason Weber Avatar answered Nov 15 '22 12:11

Jason Weber