asp.net-mvc 如何使用 ASP.NET MVC 在现有数据库中设置成员资格提供程序?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1121741/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I setup a Membership Provider in my existing database using ASP.NET MVC?
提问by
For some reason, the idea of setting up Membership in ASP.NET MVC seems really confusing.
出于某种原因,在 ASP.NET MVC 中设置 Membership 的想法似乎真的很混乱。
Can anyone provide some clear steps to setup the requisite tables, controllers, classes, etc needed to have a working Membership provider?
任何人都可以提供一些明确的步骤来设置必要的表、控制器、类等,以便拥有一个有效的会员资格提供者吗?
I know that the Demo that MVC ships with has an Accounts controller. However, should I be using this in my own project? What do I need to get my existing database ready if so? If not, how do I learn what I need to do to implement a membership provider?
我知道 MVC 附带的 Demo 有一个 Accounts 控制器。但是,我应该在自己的项目中使用它吗?如果是这样,我需要什么来准备现有的数据库?如果没有,我如何了解实施会员资格提供商需要做什么?
回答by J.W.
Check out this step by step blogon how to set up Membership provider in your asp.net mvc project. The sdk tool you need to get your database ready is aspnet_regsql.exe, you don't need to create a separate database to do that ( a lot of people think they have to provide a separate aspnet.db), you can run the command on your existing database, and it will create the tables, views, and stored procedures to handle the membership provider for you.
查看此分步博客,了解如何在您的 asp.net mvc 项目中设置成员资格提供程序。准备数据库所需的 sdk 工具是 aspnet_regsql.exe,您不需要创建单独的数据库来执行此操作(很多人认为他们必须提供单独的 aspnet.db),您可以运行命令在您现有的数据库上,它将创建表、视图和存储过程来为您处理成员资格提供程序。
However, should I be using this in my own project? What do I need to get my existing database ready if so? If not, how do I learn what I need to do to implement a membership provider?
但是,我应该在自己的项目中使用它吗?如果是这样,我需要什么来准备现有的数据库?如果没有,我如何了解实施会员资格提供商需要做什么?
The benefit to use the default provider (SqlMembership provider) is to save yourself a lot of time. It involves a lot of work to design a complete membership and role provider.
使用默认提供程序(SqlMembership 提供程序)的好处是可以节省大量时间。设计一个完整的成员资格和角色提供者需要大量的工作。
Edit [2014-06-19] Asp.Net Identity Framework is Microsoft new recommendation to manage user sand permissions.
编辑 [2014-06-19] Asp.Net Identity Framework 是 Microsoft 管理用户沙权限的新建议。
回答by Omar
Check out this link: https://github.com/TroyGoode/MembershipStarterKit
查看此链接:https: //github.com/TroyGoode/MembershipStarterKit
Most of the work is already done for you. Just download the sample project and run the aspnet_regsql.exe against your database.
大多数工作已经为您完成。只需下载示例项目并针对您的数据库运行 aspnet_regsql.exe。
回答by griegs
check out my answer in this post;
查看我在这篇文章中的回答;
If you want to keep the membership provider that .Net creates for you then you can copy all the tables etc to another sql database and point the provider at it via the config file.
如果您想保留 .Net 为您创建的成员资格提供程序,那么您可以将所有表等复制到另一个 sql 数据库,并通过配置文件将提供程序指向它。
Post a comment if you need more than this.
如果您需要更多,请发表评论。

