Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is the IdentityUser class in the Microsoft.AspNet.Identity.EntityFramework namespace and not in the Core package?

Why is the IdentityUser class in the Microsoft.AspNet.Identity.EntityFramework package instead of being included in the Microsoft.AspNet.Identity.Core package?

Why should it depend on EntityFramework? It seems to be a simple class.

What am I missing?

I typically separate by Data layer from my DAL. Adding a dependency to EntityFramework for the IdentityUser class seems a bit much.

like image 553
Issa Fram Avatar asked Jun 14 '15 23:06

Issa Fram


1 Answers

You asked:

Why is the IdentityUser class in the Microsoft.AspNet.Identity.EntityFramework package...Why should it depend on EntityFramework?

This is because the out-of-the-box implementation for Identity actually depends on Entity Framework.

The ASP.NET site has the following article: Overview of Custom Storage Providers for ASP.NET Identity which indicates:

By default, the ASP.NET Identity system stores user information in a SQL Server database, and uses Entity Framework Code First to create the database. For many applications, this approach works well. However, you may prefer to use a different type of persistence mechanism, such as Azure Table Storage, or you may already have database tables with a very different structure than the default implementation. In either case, you can write a customized provider for your storage mechanism and plug that provider into your application.

The same page also should answer your question in the comments about creating a custom implementation of IUser:

Customize the user class

When implementing your own storage provider, you must create a user class which is equivalent to the IdentityUser class in the Microsoft.ASP.NET.Identity.EntityFramework namespace:

like image 108
David Tansey Avatar answered Oct 05 '22 11:10

David Tansey