简体   繁体   中英

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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM