Asp.net 如何将代码优先实体框架4构建的数据库与远程服务器上的成员身份同步
我已经开始使用SQL Express 2008 R2构建ASP net MVC 2.0 web应用程序。我正在somee.com上托管这个应用程序 我决定使用EntityFramework4和数据库的代码优先实现,以便能够轻松地更改设计。它在本地运行良好,但当我将其部署到主机提供程序上时,会出现很多问题 首先,如果模型发生了变化,我无法重新初始化数据库,因为数据库大部分是在托管网站上预先创建的。因此,我没有这样做的权限 因此,我决定在本地服务器SQLEXPRESS上获取.mdf文件并将其发送到主机服务器,但由于某种原因,当我注册一个具有成员资格的新用户时,我无法连接到数据库。异常发生的位置是:Asp.net 如何将代码优先实体框架4构建的数据库与远程服务器上的成员身份同步,asp.net,entity-framework-4,code-first,membership,remote-server,Asp.net,Entity Framework 4,Code First,Membership,Remote Server,我已经开始使用SQL Express 2008 R2构建ASP net MVC 2.0 web应用程序。我正在somee.com上托管这个应用程序 我决定使用EntityFramework4和数据库的代码优先实现,以便能够轻松地更改设计。它在本地运行良好,但当我将其部署到主机提供程序上时,会出现很多问题 首先,如果模型发生了变化,我无法重新初始化数据库,因为数据库大部分是在托管网站上预先创建的。因此,我没有这样做的权限 因此,我决定在本地服务器SQLEXPRESS上获取.mdf文件并将其发送到主
_provider.CreateUser(userName, password, email, null, null, true, null, out status);
错误:
无法打开登录请求的数据库“人员”。登录失败。用户“dalya”登录失败
现在,我有一种感觉,通过在本地SQL EXPRESS server的DATA文件夹中获取mdf文件,权限可能与most提供商附加文件时提供的权限不同。不过,下面是我的Web.config文件:
<?xml version="1.0"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<connectionStrings>
<!--
<add name="People" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;Initial Catalog=People;"
providerName="System.Data.SqlClient" />
-->
<add name="People"
connectionString="Data source=PraxtPeople.mssql.somee.com;
packet size=4096;
user id=dalya;
pwd=********;
persist security info=False;
initial catalog=People;
"
providerName="System.Data.SqlClient"/>
</connectionStrings>
<appSettings>
<add key="DefaultConnectionString" value="People"/>
<add key="webpages:Version" value="1.0.0.0"/>
<add key="ClientValidationEnabled" value="true"/>
<add key="UnobtrusiveJavaScriptEnabled" value="true"/>
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
<membership>
<providers>
<clear/>
<add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="People"
enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false"
maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10"
applicationName="/" />
</providers>
</membership>
<profile>
<providers>
<clear/>
<add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="People" applicationName="/" />
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
<add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="People" applicationName="/" />
<add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
</providers>
</roleManager>
<pages>
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
谁能告诉我如何解决这个问题?或者有谁知道一个好的主机提供程序,它允许代码优先实体框架4.0实现,在运行时使用成员身份的数据库可以在设计更改时轻松地重新创建
感谢您的帮助,尝试更改
持久安全信息=False
topersist security info=True代码>没有共享主机允许您通过代码重新创建数据库。为此,您需要自己的服务器(或虚拟服务器主机)。