在虚拟主机托管期间无法连接到LocalDB

时间:2016-02-23 13:24:08

标签: c# asp.net asp.net-mvc asp.net-identity

我正在使用asp.net identity方法EF data first。在localhost上一切正常。我在appharbor上托管了我的网站。除AccountController之外,我的所有控制器操作和webapi都正常工作。当用户尝试注册时,会给出Internal server error。错误的细节是: enter image description here

注意:我的数据库查询工作正常。这意味着连接字符串没有问题。

启用远程连接SQL Server Network Configuration没有Protocols for SQLEXPRESS选项 enter image description here

我该如何解决这个问题?

更新 我在web.config中的连接字符串是:

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-Inspinia_MVC5_SeedProject-20141215093835.mdf;Initial Catalog=aspnet-Inspinia_MVC5_SeedProject-20141215093835;Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="Entities" connectionString="metadata=res://*/Models.Model1.csdl|res://*/Models.Model1.ssdl|res://*/Models.Model1.msl;provider=System.Data.SqlClient;provider connection string=&quot;Server=b1ad1f3e-1ab5-4169-93f8-a5ae006f3e4e.sqlserver.sequelizer.com;Database=8a5ae006f3e4e;User ID=namucclqps;Password=54nWBkCfURyMzYfhbu8NUQb6PEZUsWcoN;&quot;" providerName="System.Data.EntityClient" />

  </connectionStrings>

更新2: 我安装了SQL Server Management Studio。然后我在appharbor上托管了我的网站并安装了加载项SQL Server。然后使用以下信息连接到服务器。enter image description here

然后在SQL Server Management Studio中添加了表格,并更改了web.config和已发布网站中的连接字符串。

1 个答案:

答案 0 :(得分:0)

LocalDB只是Visual Studio中的一个东西。甚至无法在生产服务器上获取它。您需要安装某个版本的SQL Server,然后在那里创建数据库和表。

之后,将原始连接字符串保留在Web.config中,而是在Web.Release.config中添加一个转换,将连接字符串更改为数据库的生产SQL Server实例的连接字符串。最后,在发布您的网站时,请选择&#34;发布&#34;组态。然后,Web.config将在发布期间进行转换,并在部署站点后引用生产数据库。

相关问题