System.Data.SqlClient.SqlException'发生在EntityFramework.dll中,但未在用户代码中处理

时间:2015-06-19 21:41:26

标签: c# sql-server asp.net-mvc entity-framework

我使用c#(开始工作)。起初我创建了模型。通过这个模型,我使用Entity Framework创建了带有视图的MVC 5控制器。我认为一切正确(必要的表将由此模型创建,我可以使用本地数据库),但是当我想运行我的应用程序并转到此页面http://localhost:49640/ControllerName时,我收到此错误:< / p>

Additional information: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 52 - Unable to locate a Local Database Runtime installation. Verify that SQL Server Express is properly installed and that the Local Database Runtime feature is enabled.)

我试图找到一些解决方案,但我没有。据我所知,connectionStrings中的Web.config或连接到服务器的问题可能存在一些问题,但是如何解决这个问题呢?

我的连接字符串:

<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MusicApplication-20150620120938.mdf;Initial Catalog=aspnet-MusicApplication-20150620120938;Integrated Security=True"
  providerName="System.Data.SqlClient" />

1 个答案:

答案 0 :(得分:2)

我下载SqlLocalDb并安装它,这解决了我的问题。这个链接connection to local db failed 52帮助了我。