SQL “System.Web.Security.SqlMembershipProvider”需要与架构版本“1”兼容的数据库架构
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3292794/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'
提问by Arunabh Das
I have a SQL Server 2008 DB with many tables filled with data and I used SQL Server Management Studio to generate a SQL dump by using the Script Wizard : Tasks -> Generate Scripts -> Script All objects in the selected database and also selecting the option to Script Data. I made sure to change the value of "Script for Server Version" to "SQL Server 2008". Then I created a new DB and ran the SQL dump on the new DB to generate an identical copy of the old DB. Then I assigned permissions to my default user to the new DB. Then I changed the connection string on my ASP.NET application to use the new DB. But when I run it, it throws the following exception -
我有一个 SQL Server 2008 数据库,其中包含许多填充数据的表,我使用 SQL Server Management Studio 通过使用脚本向导生成 SQL 转储:任务 -> 生成脚本 -> 编写所选数据库中的所有对象并选择选项脚本数据。我确保将“服务器版本脚本”的值更改为“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
采纳答案by Tobiasopdenbrouw
If you really haven't forgotten anything (views, SP's, etc. etc. etc.), then googling indicates that 'silly' solutions like closing the project and re-opening, rebuilding, or:
如果你真的没有忘记任何东西(视图、SP 等等等等),那么谷歌搜索表明“愚蠢”的解决方案,比如关闭项目并重新打开、重建,或者:
The thing that actually did the trick was going through the ASP.NET Configuration utility (Visual Studio - under Website menu), taking the application offline and then back online. This actually just makes a change to web.config (not exactly sure what the change was). So after taking it offline, I had to upload web.config to the hosted solution. Then took the application back online, recopied web.config, etc.
真正做到这一点的事情是通过 ASP.NET 配置实用程序(Visual Studio - 在网站菜单下),使应用程序脱机,然后重新联机。这实际上只是对 web.config 进行了更改(不完全确定更改是什么)。因此,在脱机后,我必须将 web.config 上传到托管解决方案。然后将应用程序重新上线,重新复制 web.config 等。
May be the answer.
可能就是答案。
回答by arunendra
I have found a very simple way, just paste this data in the aspnet_SchemaVersions
table
我找到了一个非常简单的方法,只需将这些数据粘贴到aspnet_SchemaVersions
表格中即可
common 1 True
health monitoring 1 True
membership 1 True
personalization 1 True
profile 1 True
role manager 1 True
I had to use a few spaces to make the data aligned, ignore the blank spaces
我不得不使用一些空格使数据对齐,忽略空格
回答by GibboK
I had a similar problem and I was able to solved it adding the default value to table aspnet_SchemaVersions. This default values were not added to the DB generated using Tasks -> Generate Scripts.
我有一个类似的问题,我能够解决它,将默认值添加到表 aspnet_SchemaVersions。此默认值未添加到使用任务 -> 生成脚本生成的数据库中。
Here a useful post
这里有一个有用的帖子
INSERT INTO dbo.aspnet_SchemaVersions
VALUES
('common', 1, 1),
('membership', 1, 1),
('role manager', 1, 1);
GO
回答by Phill Q
Restarting the app pool worked for me
重新启动应用程序池对我有用
回答by Mohit Verma
Try updating the web config file with correct version of System.Web.Security.SqlRoleProvider
尝试使用正确版本的 System.Web.Security.SqlRoleProvider 更新 Web 配置文件
You can find the below configuration in c:/windows/microsoft.net/framework/v4.0.30319 or any other version , there you can find config file . Into it check for machine config files to get version & public key.
您可以在 c:/windows/microsoft.net/framework/v4.0.30319 或任何其他版本中找到以下配置,在那里您可以找到配置文件。进入它检查机器配置文件以获取版本和公钥。
For .net frameowork 4.0
对于 .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>
for .net framework 2.0
.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>
回答by Fritz
I am not at all a SQL or ASP.net guru or programmer, got the job by accident, but I had the same issue and the mistake was silly:
我根本不是 SQL 或 ASP.net 专家或程序员,偶然得到了这份工作,但我遇到了同样的问题,错误很愚蠢:
In my Web.Conf
the connection strings would usualy look something like this:
在我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" />
Yet yesterday I accidently had my source looking like this "Data Source=./SQLEXPRESS"
.
然而昨天我不小心让我的来源看起来像这样"Data Source=./SQLEXPRESS"
。
And I got the same error as discussed.
我得到了与讨论相同的错误。
This mistake would also explain why when taking the site offline and back online with Visual Studio's utility or when recompiling it would fix the error.
这个错误也可以解释为什么当使用 Visual Studio 的实用程序使站点脱机并重新联机时或重新编译它时会修复错误。
回答by hanzolo
You may have to run aspnet_regsql.exe in order to get your schema values populated. You can hard-code the values as well as long as you have all of the generated objects (tables, views, sproc's, etc..
您可能必须运行 aspnet_regsql.exe 才能填充架构值。只要您拥有所有生成的对象(表、视图、sproc 等),您就可以对这些值进行硬编码。
The steps i took to resolve this which worked was:
我为解决此问题而采取的步骤是:
re-ran aspnet_regsql.exe ensured the default values where there restarted IIS.
重新运行 aspnet_regsql.exe 确保重新启动 IIS 的默认值。
Then it worked..
然后它起作用了..
But if you just copy the database schema without the values, you need to run 'aspnet_regsql.exe' in order to populate the default values.
但是,如果您只复制没有值的数据库架构,则需要运行“aspnet_regsql.exe”以填充默认值。
the file can be found here (re: msdn): [drive:]\%windir%\Microsoft.NET\Framework\version (it's in 2.0 dir)
该文件可以在这里找到(re: msdn):[drive:]\%windir%\Microsoft.NET\Framework\version(它在 2.0 目录中)
and here's some info:
http://msdn.microsoft.com/en-us/library/ms229862%28v=vs.80%29.aspx
这里有一些信息:http:
//msdn.microsoft.com/en-us/library/ms229862%28v=vs.80%29.aspx
回答by Behzad
In my case neither of above solutions worked.
就我而言,上述解决方案均无效。
I removed applicationName="/" from memnership provider in webconfig which was created by visual studio and then uploaded it to server.
我从由 Visual Studio 创建的 webconfig 中的 memnership provider 中删除了 applicationName="/",然后将其上传到服务器。
Or you can crate the application row in aspnet_Applications table manually.
或者您可以手动创建 aspnet_Applications 表中的应用程序行。
Have a nice coding!
有一个很好的编码!
回答by jtoth3
I tried many of the options above, but none of them seemed to resolve the issue at the time (although they mayhave helped and I didn't realize it).
我尝试了上面的许多选项,但当时它们似乎都没有解决问题(尽管它们可能有所帮助,但我没有意识到)。
The last step I took [that worked] was granting the SQL user in my connection string access to the aspnet_* roles installed by aspnet_regsql.exe. My SQL user was setup as a db_owner on the database, but wasn't a sysadmin on the box - not sure if that matters.
我采取的最后一步 [有效] 是在我的连接字符串中授予 SQL 用户访问由 aspnet_regsql.exe 安装的 aspnet_* 角色的权限。我的 SQL 用户被设置为数据库上的 db_owner,但不是系统管理员 - 不确定这是否重要。
As soon as I did that, and afterI'd already tried some of the options above, everything worked great.
一旦我这样做了,并且在我已经尝试了上面的一些选项之后,一切都很好。
回答by Rob Scott
Old post, but I had an alternate solution.
旧帖子,但我有一个替代解决方案。
My connection strings in the web.config
included Persist Security Info=True;
in them. Removing this solved the error.
我的连接字符串web.config
包含Persist Security Info=True;
在其中。删除它解决了错误。