在的AccountController ASP.NET MVC使用MySQL [英] AccountController using MySQL in ASP.NET MVC
问题描述
创建在Visual Studio中默认的ASP.NET MVC项目建立了一个基本的项目,您可以将用户注册。我将如何去改变这种使用MySQL服务器,而不是SQLServer的?
Creating a default ASP.NET MVC project in Visual Studio sets up a basic project where you can register a user. How would I go on changing this to use a MySQL server instead of SQLServer ?
推荐答案
得到它现在的工作。
- 安装最新的连接器/ NET(V
6.0.4.0目前) -
替换默认连接字符串
在类似的web.config:
- Install the latest Connector/NET (v 6.0.4.0 currently)
Replace the default connection string in web.config with something like:
<添加名称=ApplicationServices的connectionString =服务器= 192.168.1.30;用户ID = thsuser;密码= thepass;数据库= thedatabase的providerName =MySql.Data.MySqlClient/>
<add name="ApplicationServices" connectionString="server=192.168.1.30;user id=thsuser;Password=thepass;database=thedatabase" providerName="MySql.Data.MySqlClient"/>
在web.config中的部分添加以下内容(为6.0.4.0的MySQL Connector ATLEAST),添加
Under the section in web.config add the following (for the 6.0.4.0 mysql connector atleast), add
&LT;添加autogenerateschema =真的connectionStringName =ApplicationServices
enablePasswordRetrieval =假enablePasswordReset设置=真requiresQuestionAndAnswer =假
requiresUniqueEmail =假了passwordFormat =散列maxInvalidPasswordAttempts =5
minRequiredPasswordLength =6minRequiredNonalphanumericCharacters =0
passwordAttemptWindow =10passwordStrengthRegularEx pression =
的applicationName =/NAME =MySQLMembershipProviderTYPE =MySql.Web.Security.MySQLMembershipProvider,MySql.Web,版本= 6.0.4.0,文化=中性公钥= c5687fc88969c44d/&GT;
<add autogenerateschema="true" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" applicationName="/" name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.0.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
运行该项目,回去到Visual Studio,然后单击解决方案资源管理上面的ASP.NET配置按钮。
Run the project, go back into Visual Studio and click the ASP.NET Configuration button above the solution explorer.
导航到提供程序配置 - >选择各功能的不同供应商,并选择MySQLMembershipProvider
Navigate to "Provider Configuration"->"Select a different provider for each feature " and select the "MySQLMembershipProvider"
作品ATLEAST注册和从MySQL数据库中记录的MySQLMembershipProvider将自动生成所需的表。
Works atleast for registering and logging in from a mysql database, the MySQLMembershipProvider will autogenerate the needed tables.
这篇关于在的AccountController ASP.NET MVC使用MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!