“System.Web.Security.SqlMembershipProvider”需要与模式版本“1”兼容的数据库模式

我有一个SQL Server 2008数据库与许多表填充数据,我用SQL Server Management Studio生成一个SQL转储通过使用脚本向导:任务 – >生成脚本 – >脚本选定的数据库中的所有对象,也select选项脚本数据。 我确保将“服务器版本的脚本”的值更改为“SQL Server 2008”。 然后,我创build了一个新的数据库,并在新数据库上运行SQL转储,以生成旧数据库的相同副本。 然后我将权限分配给我的默认用户到新的数据库。 然后我改变了我的ASP.NET应用程序的连接string以使用新的数据库。 但是当我运行它时,会抛出以下exception –

Server Error in '/myapp' Application. The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Configuration.Provider.ProviderException: The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [ProviderException: The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'. However, the current database schema is not compatible with this version. You may need to either install a compatible schema with aspnet_regsql.exe (available in the framework installation directory), or upgrade the provider to a newer version.] System.Web.Util.SecUtility.CheckSchemaVersion(ProviderBase provider, SqlConnection connection, String[] features, String version, Int32& schemaVersionCheck) +1977772 System.Web.Security.SqlMembershipProvider.CheckSchemaVersion(SqlConnection connection) +89 System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +815 System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105 System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42 System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +78 System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +60 System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +119 System.Web.UI.WebControls.Login.AttemptLogin() +115 System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37 System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565 

如果你真的没有忘记任何东西(视图,SP等等),那么Google的search表明,“愚蠢”的解决scheme,如closures项目,重新开放,重build或:

实际上做的窍门是通过ASP.NETconfiguration实用程序(Visual Studio – 在网站菜单下),使应用程序脱机,然后重新联机。 这实际上只是对web.config进行更改(不完全确定更改是什么)。 所以脱机后,我不得不上传web.config到托pipe的解决scheme。 然后将应用程序重新在线,重新设置web.config等。

可能是答案。

我发现了一个非常简单的方法,只需将这些数据粘贴到aspnet_SchemaVersions表中即可

 common 1 True health monitoring 1 True membership 1 True personalization 1 True profile 1 True role manager 1 True 

我不得不使用一些空格来使数据alignment,忽略空格

我有一个类似的问题,我能解决它添加到表aspnet_SchemaVersions的默认值。 此默认值未添加到使用“任务” – >“生成脚本”生成的数据库中。

这里有一个有用的职位

 INSERT INTO dbo.aspnet_SchemaVersions VALUES ('common', 1, 1), ('membership', 1, 1), ('role manager', 1, 1); GO 

重新启动应用程序池为我工作

我不是一个SQL或ASP.net的专家或程序员,偶然得到了这份工作,但我有同样的问题,错误是愚蠢的:

在我的Web.Conf连接string通常会看起来像这样:

 <add name="AgriConnectionString" connectionString="Data Source=.\SQLEXPRESS; Initial Catalog=AgriBranch; pooling=true; Connection Timeout=120; Integrated Security=false;Persist Security Info=True; User ID=UserID; Password=PASS***WORD" providerName="System.Data.SqlClient" /> 

然而,昨天我无意中看到我的源代码是"Data Source=./SQLEXPRESS"

我也遇到了同样的错误。

这个错误也可以解释为什么当使用Visual Studio的实用程序将网站脱机并重新联机时,或者重新编译它时将修复错误。

尝试使用正确版本的System.Web.Security.SqlRoleProvider更新Webconfiguration文件

您可以在c:/windows/microsoft.net/framework/v4.0.30319或任何其他版本中find以下configuration,在那里您可以findconfiguration文件。 进入它检查机器configuration文件获取版本和公钥。

对于.net框架4.0

  <roleManager enabled="true" defaultProvider="SqlProvider"> <providers> <clear/> <add name="SqlProvider" connectionStringName="rolesDB" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </providers> </roleManager> 

为.net框架2.0

  <roleManager enabled="true" defaultProvider="SqlProvider"> <providers> <clear/> <add name="SqlProvider" connectionStringName="rolesDB" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/> </providers> </roleManager> 

您可能需要运行aspnet_regsql.exe以获取您的模式值填充。 您可以对值进行硬编码,只要您拥有所有生成的对象(表,视图,贴图等等)。

我采取的步骤来解决这个工作是:

重新运行aspnet_regsql.exe确保在那里重新启动IIS的默认值。

然后它的工作..

但是,如果只是复制没有值的数据库模式,则需要运行“aspnet_regsql.exe”以填充默认值。

这个文件可以在这里find(re:msdn):[drive:] \%windir%\ Microsoft.NET \ Framework \ version(在2.0目录下)

这里有一些信息:
http://msdn.microsoft.com/en-us/library/ms229862%28v=vs.80%29.aspx

在我的情况下,上述解决scheme都没有工作

我从由visio studio创build的webconfig中的memnership provider中删除了applicationName =“/”,然后将其上传到服务器。

或者,您可以手动在aspnet_Applications表中创build应用程序行。

有一个很好的编码!

我尝试了上面的许多选项,但是当时似乎没有一个能够解决这个问题(虽然他们可能有帮助,但我没有意识到)。

我采取的最后一个步骤是授予SQL用户在我的连接string访问由aspnet_regsql.exe安装的aspnet_ *angular色。 我的SQL用户被设置为数据库上的db_owner,但不是系统pipe理员 – 不知道是否重要。

只要我这样做,而且我已经尝试了上面的一些选项,一切都很好。

忘记在我的新数据库上运行aspreg_sql后,我第一次收到这个错误。 一旦完成,我收到这个错误,直到我closuresCassini或ASP.NET开发服务器。 重新运行,它工作正常。

这基本上是当你复制/过去完整的网站解决scheme。 SQL Server的ASP.NETconfiguration应该单独configuration。 这意味着您应该从Visual Studio命令提示符下运行aspnet_regsql,并在向导期间相应地按照说明进行操作。

旧post,但我有一个替代解决scheme。

我的连接string在web.config包括Persist Security Info=True; 在他们中。 删除这个解决了错误。