'System.Web.Security.SqlMembershipProvider'需要与架构版本'1'兼容的数据库架构

Aru*_*Das 56 sql asp.net

我有一个SQL Server 2008数据库,其中有许多表填充了数据,我使用SQL Server Management Studio通过脚本向导生成SQL转储:任务 - >生成脚本 - >脚本所选数据库中的所有对象,还选择选项脚本数据.我确保将"Script for Server Version"的值更改为"SQL Server 2008".然后我创建了一个新数据库,并在新数据库上运行SQL转储,以生成旧数据库的相同副本.然后我将默认用户的权限分配给新数据库.然后我更改了ASP.NET应用程序上的连接字符串以使用新数据库.但是当我运行它时,会抛出以下异常 -

            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
Run Code Online (Sandbox Code Playgroud)

小智 105

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

common              1   True
health monitoring   1   True
membership          1   True
personalization     1   True
profile             1   True
role manager        1   True
Run Code Online (Sandbox Code Playgroud)

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

  • 使用此解决方案,无需重新编译,只需重新启动站点即可完成 (3认同)

Tob*_*ouw 47

如果你真的没有忘记任何事情(观点,SP等等),那么谷歌搜索表明'愚蠢'的解决方案,如关闭项目,重新开放,重建,或:

真正做到这一点的是通过ASP.NET配置实用程序(Visual Studio - 在网站菜单下),使应用程序脱机然后重新联机.这实际上只是对web.config进行了更改(不完全确定更改是什么).因此,在将其脱机后,我必须将web.config上传到托管解决方案.然后将应用程序重新联机,重新复制web.config等.

可能是答案.

  • 是的 - 关键似乎是你所说的web.config的变化.我只是打开我的web.config,添加了一个空格,删除了该空格并点击了save.立即开始工作.谢谢你给出了彻底的答复! (2认同)
  • 通过IIS管理器重新启动IIS对我有用. (2认同)

Gib*_*boK 39

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

这是一个有用的帖子

INSERT INTO dbo.aspnet_SchemaVersions 
VALUES
('common', 1, 1),
('membership', 1, 1),
('role manager', 1, 1);
GO
Run Code Online (Sandbox Code Playgroud)


小智 13

重新启动应用程序池对我有用

  • 这让我想哭 (7认同)

小智 6

我根本不是SQL或ASP.net的大师或程序员,偶然得到了这份工作,但我遇到了同样的问题而且这个错误很愚蠢:

在我Web.Conf的连接字符串中通常看起来像这样:

<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" />
Run Code Online (Sandbox Code Playgroud)

然而昨天我意外地让我的消息来源看起来像这样"Data Source=./SQLEXPRESS".

我得到了与讨论相同的错误.

这个错误也可以解释为什么当使用Visual Studio的实用程序使站点脱机并重新联机时,或者重新编译时会解决错误.


Moh*_*rma 5

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

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

对于.net frameowork 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>
Run Code Online (Sandbox Code Playgroud)

for .net framework 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>
Run Code Online (Sandbox Code Playgroud)