Can't connect LinqPad to my EF model

edited December 2015
Hello,

We have a mature EF4 model in a large solution, and I want to connect LinqPad (v5.02.03) to it, so I can test queries. However, I can't seem to get it working. I can't just connect directly to the database, as the model contains a lot of modifications, which mean that writing queries directly against the model won't help for using them in the code.

If it makes any difference, for our sins, we are using the Self-Tracking Entities TT4 template that Microsoft produced years ago. They've since deprecated it, but we are too far down the line to change the model.

We have separate projects in Visual Studio for the following...

Data - This contains the EF model, ie the .edmx file
Entities - This contains the .tt file, and therefore the .cs files for the entities themselves
DAL - This contains our repository classes, but also has the context TT4 file, so contains the .cs file for the ObjectContext-derived class.

Here's what I did to try and connect...

1) Create a new connection, and choose the Entity Framework (ObjectContext) driver

2) In the Path to Custom Assembly section, I click the Browse link and pick the DAL assembly

3) In the Full Name of Typed ObjectContext section, I couldn't find anything that would work by using the Choose link, so I ended up typing MyProject.Entities.SalesTrackerCRMEntities in manually. I got this by opening the ObjectContext-derived class and copying the info

4) In the next section (Path to Entity Data Model), I clicked the Choose link, and browsed to the Data\obj\Debug\edmxResourcesToEmbed folder, and selected one of the files. This put MyModel.csdl|MyModel.msl|MyModel.ssdl in the textbox.

5) I entered 127.0.0.1 in the Server textbox, chose SQL Authentication and entered the uid and pwd.

6) I clicked the Specify new or existing database radio button and chose the database from the dropdown.

All seemed to be going well, but if I now try and test the connection, I get an exception...

The specified metadata path is not valid. A valid path must be either an existing directory, an extension file with extension '.csdl', '.ssdl' or '.msl' or a URI that identifies an embedded resource.

Anyone any ideas what this means and how I fix it?

I tried modifying the Path to Entity Data Model to include a relative path from the model to the resource files...

..\..\..\Data\obj\Debug\edmxResourcesToEmbed\MyModel.csdl|..\..\..\Data\obj\Debug\edmxResourcesToEmbed\MyModel.msl|..\..\..\Data\obj\Debug\edmxResourcesToEmbed\MyModel.ssdl

...but that gave the same error.

How can I connect to this model? Thanks for any help you can give. Please let me know if there's any more information I need to supply.

Comments

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!