Error: 25 - Connection string is not valid

Oct 14, 2010 at 8:21 AM
Edited Oct 14, 2010 at 8:31 AM

Hello friends!

I have a problem with my database server configuration so that  I cannot create the Entity Data Model.

I'm using MS Visual Studio 2010 and MS SQL Server 2008 with default instance name MSSQLSERVER.

 

When I tried to open MvcMusicStore.mdf using Server Explorer window, I got Server Explorer Error...

"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: 25 - Connection string is not valid)."

 

And here is the entity connection string:

metadata=res://*/Models.StoreDB.csdl|res://*/Models.StoreDB.ssdl|res://*/Models.StoreDB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\MSSQLSERVER;AttachDbFilename=|DataDirectory|\MvcMusicStore.mdf;Integrated Security=True;User Instance=True"

 

I checked SQL Server Instance Name on Tools > Options > Database Tools > Data Connections and I found it correct (MSSQLSERVER).

Thank you for your information. I'm really appreciate it.

Coordinator
Oct 15, 2010 at 5:34 PM

There are two options for setting up the database. You can attach to a database file using SQL Server Express, which is normally installed with Visual Studio 2010, or you can use an instance of SQL Server 2008. Right now you've got a mix of both - you're attaching to a database file but using an instance of SQL Server 2008.

If you have SQL Server Express installed, you should be able to change your connection string to:
metadata=res://*/Models.StoreDB.csdl|res://*/Models.StoreDB.ssdl|res://*/Models.StoreDB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\MvcMusicStore.mdf;Integrated Security=True;User Instance=True"

Alternatively, you can run the SQL Create Scripts (included in the latest download zip and linked to on the home page of the project: http://mvcmusicstore.codeplex.com) to create a database on your MSSQLSERVER instance. In that case, your connection string would probably look like:
metadata=res://*/Models.StoreDB.csdl|res://*/Models.StoreDB.ssdl|res://*/Models.StoreDB.msl;provider=System.Data.SqlClient;provider connection string="Data Source=.\MSSQLSERVER;Database=MvcMusicStore;Integrated Security=True;"

More information on connection strings here: http://connectionstrings.com/sql-server-2008