jdavis
jdavis

Reputation: 8655

Cannot connect to Database with Entity Framework

Every time I have a fresh install of Windows, Visual Studio and Sql Server I always have problems getting an application to connect to the local instance of Sql Server.

I am trying to start an application using Entity Framework code first. Here is my connection string.

<add name="KCSoccerDataContext" 
     connectionString="Data Source=.\MSSQLSERVER;Initial Catalog=KCSoccer;Integrated Security=SSPI" 
     providerName="System.Data.SqlClient" />

I am able to connect to the database instance using Sql Server Management Studio, but can't seem to connect using this connection string. I am assuming the problem has to do with how the database instance is configured.

The error I'm getting is

{"The provider did not return a ProviderManifestToken string."}

I'm not exactly sure what this means or where to go from here.

Any help anyone could give on this would be awesome.

Thanks

Upvotes: 0

Views: 5145

Answers (2)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364249

Use just this connection string:

<add name="KCSoccerDataContext" 
     connectionString="Data Source=.;Initial Catalog=KCSoccer;Integrated Security=SSPI" 
     providerName="System.Data.SqlClient" />

MSSQLSERVER is name of default instance. It is not used in connection strings. It even doesn't work from Management studio if you try using it. Only names of custom instances must by used.

Upvotes: 3

Amr
Amr

Reputation: 1985

You probably didn't enable remote connections for SQL Server since it's a fresh installation. Follow first solution here or here.

Upvotes: 0

Related Questions