使用asp.net 5 MVC 6与身份和EF 6的示例 [英] Example of using asp.net 5 MVC 6 with Identity and EF 6
问题描述
我设置了EF 6.1.3,这是正常工作。
身份3.0取决于EF 7,所以我已经删除了,并在身份2.2
中引用,但我我不知道从哪里去。
我不知道在最终版本中如何处理ASP.NET 5,但在ASP.NET 5 RC1的情况下,我们有以下内容:
首先,您应该使用Identity 3.0,因为没有办法根据我所知,使用MVC 6中的Identity 2.x。
其次,为了使Identity 3.0与EF6配合使用,您需要实现自己的EF6友好 Microsoft.AspNet.Identity.EntityFramework命名空间下的所有类的版本(代码在此可用 - https ://github.com/aspnet/Identity/tree/3.0.0-rc1/src/Microsoft.AspNet.Identity.EntityFramework ),因为原始类仅适用于EF7:
- IdentityDbContext
- RoleStore
- UserStore
- IdentityRole
- IdentityRoleClaim
- IdentityUser
- IdentityUserClaim
- IdentityUserLogin
- IdentityUserRole
您的实现应使用EF6而不是EF7。这个过程很简单,但是如果你想节省时间,我在这里分享了我的实现:
https://github.com/EntrypointSoft/AspNet.Identity.EntityFramework6
I'm setting up a new project using asp.net 5 and MVC 6, but I want to use Entity Framework 6 due to the missing features in EF 7.
I setup EF 6.1.3 and that is working.
Identity 3.0 depends on EF 7 so I have removed that and referenced in Identity 2.2 but I'm not sure where to go from here.
I'm not sure how this will be handled in the final release of ASP.NET 5, but in the case of ASP.NET 5 RC1 we have the following:
Firstly, you should go with Identity 3.0, as there is no way to use Identity 2.x in MVC 6 as far as I know.
Secondly, to make Identity 3.0 work with EF6, you need to implementation your own "EF6-friendly" versions of all classes under Microsoft.AspNet.Identity.EntityFramework namespace (the code is available here- https://github.com/aspnet/Identity/tree/3.0.0-rc1/src/Microsoft.AspNet.Identity.EntityFramework), as original classes are meant to work with EF7 only:
- IdentityDbContext
- RoleStore
- UserStore
- IdentityRole
- IdentityRoleClaim
- IdentityUser
- IdentityUserClaim
- IdentityUserLogin
- IdentityUserRole
Your implementations should utilize EF6 instead of EF7. The process is pretty straightforward, but if you want to save time, I have shared my implementation here:
https://github.com/EntrypointSoft/AspNet.Identity.EntityFramework6
这篇关于使用asp.net 5 MVC 6与身份和EF 6的示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!