unable to initialize provider
场景:新服务器发布
系统:windows server 2012
程序环境:mysql6.9.5,iis8.5,.net4.0
错误:unable to initialize provider
分析原因:项目中采用了membership,安装新数据库时直接copy了原数据库的membership表
解决方法:步骤1.假如数据库中没有membership的表,修改machine.config (c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Config\machine.config)中添加 autogenerateschema="true",具体位置放置如下
<membership> <providers> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" /> <add name="MySQLMembershipProvider" type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionStringName="LocalMySqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" autogenerateschema="true"/> </providers> </membership>
2.删除数据库中的membership表,重启启动项目将自动生成相对应数据库表,生成成功