难道没有实体框架和SQL Server新的ASP.NET MVC框架的身份工作? [英] Does new ASP.NET MVC identity framework work without Entity Framework and SQL Server?
问题描述
我是新来的ASP.NET MVC 5,因此我尝试使用它尽可能多地通过实践来学习它。
I am new to ASP.NET MVC 5 and so I am trying to use it as much as possible to learn it by practice.
所以我想使用新的OWIN实施ASP.NET MVC来实现我的项目的认证和授权。这就是说,我建这个项目的方式,它可以与各种类型的数据库。
So I am thinking of using the new OWIN implementation of ASP.NET MVC to implement the authentication and authorization of my project. That said, I am building the project in a way that it can work with various types of databases.
到目前为止,我已经使用的通用ADO.NET元素(例如 DbDataReader
等),我已经拒绝使用任何ORM。所以我想知道如果我可以用ASP.NET的新的身份系统继续或将我绑定到实体框架和SQL Server,如果我这样做?
So far I have used generic ADO.NET elements (e.g. DbDataReader
etc) and I have refused to use any ORM. So I am wondering if I can go ahead with using the new identity system of ASP.NET or will I be bound to Entity Framework and SQL Server if I do so?
推荐答案
没那么简单。并不难,无论是。
Not that simple. Not that hard either.
您将必须编写的自定义实现:
You'll have to write your custom implementation of:
-
IUserStore<&TUSER GT;
-
IUserPasswordStore<&TUSER GT;
-
IUserTwoFactorStore<&TUSER GT;
-
IUserClaimStore<&TUSER GT;
-
IRoleStore< TRole>
-
IUserSecurityStampStore< TUSER,串>
-
IUserRoleStore< TUSER,串>
-
的UserManager<&TUSER GT;
IUserStore<TUser>
IUserPasswordStore<TUser>
IUserTwoFactorStore<TUser>
IUserClaimStore<TUser>
IRoleStore<TRole>
IUserSecurityStampStore<TUser, string>
IUserRoleStore<TUser, string>
UserManager<TUser>
然后创建自己的用户实现从 IUSER&LT; TKEY的&GT;
,如:
Then create your own user implementation, from IUser<TKey>
, like:
public class MyUser : IUser<string>
{
public string Id { get; set; }
public string UserName { get; set; }
}
最后,从的NuGet,删除AspNet.Identity.EntityFramework,这会太多,如果你不使用它在其他地方取出的EntityFramework。
Finally, from NuGet, remove AspNet.Identity.EntityFramework, which will remove EntityFramework too if you're not using it elsewhere.
无论您code断裂,改写它能够使用自定义的实现。
Wherever your code breaks, rewrite it to use your custom implementations.
创建它实现项MyUserRepository 1至7个
Create a MyUserRepository which implements items from 1 to 7.
比,创建一个实现项目8 MyUserManager。
Than, create a MyUserManager which implements item 8.
这将是该死的,接线方便,截至到位默认AspNet.Identity.EntityFramework类。
It will be damn easy to wire that up in place of default AspNet.Identity.EntityFramework classes.
这篇关于难道没有实体框架和SQL Server新的ASP.NET MVC框架的身份工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!