vidly-mvc-5
vidly-mvc-5 copied to clipboard
025. Unable to run Update-database
Hi,
I am unable to update the database I was first told tat VS could not find any instance of a local DB so I have installed LocalDB using SQL Server Express.
I am now greeted with the following error message:
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.)
My Connection string in web.config is as follows:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\aspnet-Vidly-20190922050545.mdf;Initial Catalog=aspnet-Vidly-20190922050545;Integrated Security=true"
Can anyone help with this?
Thanks
Update I have managed to update-database by changing the source to .\SQLEXPRESS
however I am unable to connect to the data source in server explorer when clicking the .mdf file in app data i get the following:
hey did you get the result i'm still getting the error. my previous connection string was
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|Data Directory|\aspnet-shutter-20200323030420.mdf;Initial Catalog=aspnet-shutter-20200323030420;Integrated Security=True" providerName="System.Data.SqlClient" />
then i changed source to and now
<add name="DefaultConnection" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\aspnet-shutter-20200323030420.mdf;Initial Catalog=aspnet-shutter-20200323030420;Integrated Security=True" providerName="System.Data.SqlClient" />
still getting same error i.e a network related.... can you help me with this
Change connection string as below at web.config
<add name="DefaultConnection"
connectionString="Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=aspnet-Events;Integrated Security=True"
providerName="System.Data.SqlClient" />
Then, run "Update-Database -Verbose" at package manager Thanks,
ok update-database works now but I have nothing under App_Data when clicking show all files
Hi @thelordgod ,
There is no db files creation at App_Data.
The Database will create at urs locally installed sql server..
Open Visual studio 2017\2019 IDE then click on 'View' at top of IDE and then click SQL Server Object Explorer as below
Many Thanks,
I've found it, thank you very much!