简体   繁体   中英

System.Data.SqlClient.SqlException' occurred in EntityFramework.dll but was not handled in user code

I worked with c#(started to work). At first I created model. And by this model I created MVC 5 controller with views, using Entity Framework. I thought that all correct (that necessary table will be created by this model, and I can worked with local database), but when I would like to run my application and go to this page http://localhost:49640/ControllerName I get this error:

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

I tried to find some solution, but I didn't. As I understood it can be some problems with connectionStrings in Web.config or some problems with connection to server, but how solve this problem?

My connection strings:

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

I download SqlLocalDb and installed it, this solve my problem. This link connection to local db failed 52 helped me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM