报错: 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1',如何使用?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (112)

我有一个SQLServer 2008 DB,其中有许多表填充了数据,我使用SQLServerManagementStudio通过使用脚本向导->GenerateScript->ScriptallObjects->ScriptAllObjects,并选择编写数据脚本选项来生成SQL转储。我确保将“ScriptforServerVersion”的值更改为“SQLServer 2008”。然后,我创建了一个新DB,并在新DB上运行SQL转储以生成旧DB的相同副本。然后,我将权限分配给新DB的默认用户。然后,我将ASP.NET应用程序上的连接字符串更改为使用新的DB。但当我运行它时,它会抛出以下异常:

            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等),那么googling就表示“愚蠢”的解决方案,比如关闭项目和重新打开、重建。

用户回答回答于

只需将这些数据粘贴到aspnet_SchemaVersions表:

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

我不得不使用一些空格来使数据对齐,忽略空白。

扫码关注云+社区