Decoupling Microsoft.AspNet.Identity.* entity-framework owin


I am working in Visual Studio 2013 RC and am testing Forms Authentication using new Microsoft.AspNet.Identity.* packages.

I would to integrate these concepts (Users, Roles, etc, etc) but want to use my own domain models (POCOs) which are in different assembly. I also don't want to create a dependency on Microsoft.AspNet.Identity.* dlls.

Is that even possible? I found this article which says it is not, but the article is written based on Preview not RC versions of identity packages.

9/10/2013 7:29:54 PM

Popular Answer

I have updated my sample project which you can find here: Identity RC1 sample

It now implements an entity framework model, it still require a reference to the Microsoft.AspNet.Identity.EntityFramework as I didn't want to reimplement all the Store classes also. But the sample shows how you can use your own POCO classes for the model.

If you want to completely remove the dependency on Microsoft.AspNet.Identity.EntityFramework from your model assembly you need to implement an class implementing the IIdentityStore interface which has properties of the following interfaces:

  • IUserLoginStore
  • IRoleStore
  • IUserSecretStore
  • ITokenStore
  • IUserClaimStore
  • IUserManagementStore
  • IUserStore

The IIdentityStore class should be in an assembly separate from your model assembly, with a reference to your model assembly. The IIdentityStore assembly would be dependent on ASP.Net Identity core.

Your custom implementation of IIdentityStore would need to somwhow be able to convert to and from your POCO classes to ASP.Net Identity interfaces such as IUser, IUserSecret etc.

Seems to me to be a lot of work for little gain, if you are using EF for your stores anyway.

Taking a dependency on the AspNet.Identity.Core assembly and have some of your POCO classes implementing one tiny interface each, seems a lot simpler to me.

9/12/2013 5:46:45 AM

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