connect mvc3 membership with sql database

2019-09-08 15:56发布

问题:

I am using the built-in membership for mvc3 with an online sql database, so I changed my connection string to look like this:

<connectionStrings>
   <add name="ApplicationServices" 
        connectionString="Data Source=72.18.142.170,1533;Network Library=DBMSSOCN;Initial Catalog=entertainment;User Id=uname;Password=pswd;"  
        providerName="System.Data.SqlClient"/>
</connectionStrings>

But when I try to register a new user I get the following error:

{"Invalid object name 'dbo.aspnet_SchemaVersions'."} System.Data.SqlClient.SqlException

Thank you for your help

回答1:

The table aspnet_SchemaVersions doesn't exist in the database entertainment (or at least in the default schema). (Conversely, I suppose it's possible that the user uname just doesn't have access to the table.)

You need to create the tables for the membership provider to use.