[Solved] Entity Framework Error: Local Database Runtime error occurred. Cannot create an automatic instance

on Dec 13, 2020 06:36 AM

When generate the database using entity framework code first i have face this error 

PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.

System.Data.SqlClient.SqlException (0x80131904): 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: 50 - Local Database Runtime error occurred. Cannot create an automatic instance. See the Windows Application event log for error details.)

Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Dec 14, 2020 06:05 AM

Thank you mr.dharmendr

I fix my issue by removing the default connection string and put one i have create 

The old connection string 

<add name="DefaultConnection" connectionString="Data Source=((localdb)\mssqllocaldb;AttachDbFilename=|DataDirectory|\DataBaseName-20201212031109.mdf;Initial Catalog=databaseName;Integrated Security=True" providerName="System.Data.SqlClient" />

The new

<add name="DefaultConnection" connectionString="server=serverID;AttachDbFilename=|DataDirectory|\DatabaseName-20201212031109.mdf;initial catalog=DatabaseName;integrated security = true;" providerName="System.Data.SqlClient"/>