Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is LocalDB supported by Visual Studio 2010 in Entity Framework 5?

Is LocalDB supported by Visual Studio 2010 in Entity Framework 5, on .NET 4.0?

Or am I doing it wrong? I'm getting a "The network path can't be found" issue when instantiating my model container with a connection string for LocalDB.

Here's the connection string:

var connectionString = "metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=\"data source=(localdb)\v11.0;initial catalog=fablelane_com_db;integrated security=SSPI;multipleactiveresultsets=True;App=EntityFramework\"";

Edit 1 I'm receiving the following error when connecting, more specifically:

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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server).

Edit 2 I just figured out that changing to Visual Studio 11 beta doesn't work either. Still receiving the same error-message.

like image 897
Mathias Lykkegaard Lorenzen Avatar asked Mar 15 '12 08:03

Mathias Lykkegaard Lorenzen


People also ask

Does Visual Studio install LocalDB?

Alternatively, you can install LocalDB through the Visual Studio Installer, as part of the Data Storage and Processing workload, the ASP.NET and web development workload, or as an individual component.

Can I use LocalDB in production?

Despite their differences, Microsoft still allows both to be used for production applications at no cost. LocalDB can act as an embedded database for a small application and SQL Server Express can act as a more robust, full-featured remote database engine for larger applications.

How do I use database first approach in Entity Framework?

Step 1 − Let's create a new console project with DatabaseFirstDemo name. Step 2 − To create the model, first right-click on your console project in solution explorer and select Add → New Items… Step 3 − Select ADO.NET Entity Data Model from middle pane and enter name DatabaseFirstModel in the Name field.


1 Answers

The problem was something as simple as a missing backslash to escape my database.

Notice how the database's name is "(localdb)\v11.0". The backslash in the original connectionstring is not escaped at all, so it handles "\v" as part of the connection string.

Escaping it by specifying "\\v" instead of "\v" worked.

like image 195
Mathias Lykkegaard Lorenzen Avatar answered Sep 20 '22 05:09

Mathias Lykkegaard Lorenzen