BookService icon indicating copy to clipboard operation
BookService copied to clipboard

Doesn't update database

Open hughgallagher opened this issue 8 years ago • 5 comments

How come these simple Visual Studio projects hardly ever run out of the box :) ... .Never fails to astound!

When I run the Update-Database I get the following error:-

An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct.

This is on windows 10 on a new install of visual studio 2015 community.

Is it something to do with localDB?

hughgallagher avatar Sep 20 '16 22:09 hughgallagher

Have you added the query string to your configuration file. If so does it match your own configuration?

MattSpeakman avatar Sep 21 '16 06:09 MattSpeakman

Sounds like a LocalDB problem? Do you have SQL Server 2012 Express LocalDB? (Download here)

VeronicaWasson avatar Sep 22 '16 17:09 VeronicaWasson

Got the same error, because i had sql server 2014 installed, but i fixed it by changing the web.config conn string to: <add name="BookServiceContext" connectionString="Data Source=(mssqlserver)\v12.0; Initial Catalog=BookServiceContext-20140613003603; Integrated Security=True; MultipleActiveResultSets=True; AttachDbFilename=|DataDirectory|BookServiceContext-20140613003603.mdf" providerName="System.Data.SqlClient"/> It now throws this:

update-database -verbose
Using StartUp project 'BookService'.
Using NuGet project 'BookService'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
System.ArgumentException: Invalid value for key 'attachdbfilename'.
   at System.Data.SqlClient.SqlConnectionString.VerifyLocalHostAndFixup(String& host, Boolean enforceLocalHost, Boolean fixup)
   at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
   at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
   at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
   at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)

etc

silviumihaipreda avatar Oct 21 '16 14:10 silviumihaipreda

Same issue for me.

when execute Update-Database , it gave me error msg :

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

XinCai avatar Nov 21 '16 05:11 XinCai

You need to update the query string

MattSpeakman avatar Nov 21 '16 07:11 MattSpeakman