Entity Framework Connecting to localDb

I try to follow ASP.NET MVC 4 plural principles. But can't connect to my database.

Here's my mistake:

An error occurred while retrieving supplier information from the database. It could be caused by Entity Framework using the wrong connection string. Check for internal exceptions and make sure the connection string is correct.

I have visual studio 2013 professional and SQL Server 2012 installed on my machine. When I installed my SQL Server, I created the server name "ABC" on my computer.

I also installed sql localdb 11.0 separately, but it looks like VS cannot find the localDb connection. When I check Server Explorer -> Add Connection, only "ABC" appears in the list of server names.

Here is the connection string.

I also tried using "Data Source = ABC; ...." it doesn't work either.

Update

Here is my connection string

<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;Initial Catalog=aspnet-eManager.Web-20141223223418;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnet-eManager.Web-2014122322341‌​8.mdf" providerName="System.Data.SqlClient" />

      

+3


source to share


2 answers


You can try this

  • In server explorer right click, select Add Connection
  • enter (localdb)\v11.0

    as server name
  • Select your database and click
  • Right click properties on new connection
  • Use this inline connection in your default connection

those.

<add name="DefaultConnection" connectionString="<Paste-connection-string-here>" providerName="System.Data.SqlClient" />

      


If that doesn't work, try running it from the command line

  • Open command prompt
  • Start SqlLocalDB.exe start v11.0


Follow the original steps, use a named pipe as your server name


If that doesn't work, try connecting via named pipes

  • Open command prompt
  • Run SqlLocalDB.exe info v11.0
  • Copy the name of the instance starting with np: ...

Follow the original steps, use a named pipe as your server name

eg

enter image description here

+2


source


Run this command to make sure your LocalDB version is sqllocaldb info

sqllocaldb info result result

So in my case the MSSQLLocalDB version , then the connection string would look like this:



<add name="DefaultConnection" connectionString="Data Source=(LocalDB)\MSSQLLocalDB;Initial Catalog=IdentityManagerDB;Integrated Security=True" providerName="System.Data.SqlClient" />

0


source







All Articles