Fluent API with ASP.NET Identity

Asked

Viewed 415 times

7

In accordance with this tutorial, I transported Identity in a class library to encapsulate the system’s business rule. However, the entire system is using Fluent API to map the entities and Identity generates the tables through the code first.

Is there any contraindication in performing the class mapping IdentityUser manually? It is possible to perform this process normally or there is some particularity?

2 answers

6


Is there any contraindication in performing the class mapping IdentityUser manually?

The recommended is that you keep the code on Assembly separately as close as possible to the original code of template web. ASP.NET Identity is quite responsive to customizations and is quite attached to the Entity Framework, so in theory use Fluent API is no problem as you can get an equivalent result using another approach.

Just make sure nothing was missing when changing approach.

It is possible to perform this process normally or there is some particularity?

At first there are no particularities. Just make sure to install this package and this too in the Assembly separate. There are resolved all dependencies for the correct functioning of ASP.NET Identity.

Another precaution is not to remove the original settings from your Web.config. This is due to the fact that even referencing the Assembly, the configuration will be based on the web project, and not on a file .config placed in the Assembly.

4

You can use your own custom classes with Identity.

Just implement the interfaces:

  • Iuser
  • Irole
  • Iuserstore
  • Iuserloginstore
  • Iuserrolestore
  • Iuserclaimstore
  • Iuserpasswordstore
  • Iusersecuritystampstore

It’s a lot of work, but basically you can store the authentication information however you want.

Here we are using Mongodb, for example. Take a look at Mongodb.AspNet.Identity for a full example of how to customize Identity persistence:

https://github.com/InspectorIT/MongoDB.AspNet.Identity

Browser other questions tagged

You are not signed in. Login or sign up in order to post.