The 'System.Web.Security.SqlMembershipProvider' requires a database schema compatible with schema version '1'

asp.netSql

asp.net Problem Overview


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 -

			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

asp.net Solutions


Solution 1 - asp.net

I have found a very simple way, just paste this data in the aspnet_SchemaVersions table

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

Solution 2 - asp.net

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:

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.

May be the answer.

Solution 3 - asp.net

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.

Here a useful post

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

Solution 4 - asp.net

Restarting the app pool worked for me

Solution 5 - asp.net

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:

In my Web.Conf the connection strings would usualy look something like this:

<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".

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.

Solution 6 - asp.net

Try updating the web config file with correct version of System.Web.Security.SqlRoleProvider

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.

For .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>

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>

Solution 7 - asp.net

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..

The steps i took to resolve this which worked was:

re-ran aspnet_regsql.exe ensured the default values where there restarted 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.

the file can be found here (re: msdn): [drive:]%windir%\Microsoft.NET\Framework\version (it's in 2.0 dir)

and here's some info:
http://msdn.microsoft.com/en-us/library/ms229862%28v=vs.80%29.aspx

Solution 8 - asp.net

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.

Or you can crate the application row in aspnet_Applications table manually.

Have a nice coding!

Solution 9 - asp.net

I tried many of the options above, but none of them seemed to resolve the issue at the time (although they may have 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.

As soon as I did that, and after I'd already tried some of the options above, everything worked great.

Solution 10 - asp.net

I first received this error after forgetting to run the aspreg_sql on my new db. Once done I received this error until I shut down Cassini or the ASP.NET development server. Re-ran and it worked fine.

Solution 11 - asp.net

This basically comes when you copy/past complete website solution. ASP.NET configuration for SQL server should be configured separately. Which means you should run the aspnet_regsql from Visual Studio command prompt and follow instruction accordingly during wizard.

Solution 12 - asp.net

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionArunabh DasView Question on Stackoverflow
Solution 1 - asp.netarunendraView Answer on Stackoverflow
Solution 2 - asp.netTobiasopdenbrouwView Answer on Stackoverflow
Solution 3 - asp.netGibboKView Answer on Stackoverflow
Solution 4 - asp.netPhill QView Answer on Stackoverflow
Solution 5 - asp.netFritzView Answer on Stackoverflow
Solution 6 - asp.netMohit VermaView Answer on Stackoverflow
Solution 7 - asp.nethanzoloView Answer on Stackoverflow
Solution 8 - asp.netBehzadView Answer on Stackoverflow
Solution 9 - asp.netjtoth3View Answer on Stackoverflow
Solution 10 - asp.netuser754916View Answer on Stackoverflow
Solution 11 - asp.netAltaf PatelView Answer on Stackoverflow
Solution 12 - asp.netRob ScottView Answer on Stackoverflow