Home
Options

Entity Framework: Type Name of Typed DbContext failing (unable to connect to EF)

Here are the steps taken to attempt to connect to Entity Framework:
1. After clicking on "Add Connection" in Linqpad5, I selected "Entity Framework (DbContext V4/V5/V6)

image


2. Next, from my website's "bin" folder, I selected the assembly "EntityFramework.dll".
3. After selecting this assembly, I then clicked on "Choose" for the "Full Type Name of Typed DbContext", and a pop-up "Custom Type Name" menu appears (see screenshot below). I tried each of the 5 types that appear in this menu, but they all produce the same error as shown in the screenshot below: "Error: the type must define a public parameterless constructor and/or a constructor accepting a single string parameter."

image


4. Because all of the types in this pop-up screen produced this error, I then reviewed my Web.config file to see if any other Type Names exist that would resolve the error. In the Web.config file, there is an "entityFramework" element that contains a child element "defaultConnectionFactory" with a "type" attribute of "System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework". Within this child element, a "parameters" child element exists with a single parameter (see extract from my web.config file below):

image


So I manually entered "System.Data.Entity.Infrastructure.LocalDbConnectionFactory" for the type, which appeared to work because the error disappeared after manually entering this type:

image


However, when clicking on "Test", the following error appeared that is related to this type.

image



Given that my understanding of web.config files is not thorough enough to understand if selecting "System.Data.Entity.Infrastructure.LocalDbConnectionFactory" as the Type is correct, my questions would be:
1. Is this the correct element to contain the information Linqpad5 requires for the database to address this last error?
2. If no, can anyone point to where I should be looking? Otherwise, if yes, can anyone point me to where I can find how to define the database in this element? (I tried googling this, and experimenting with what attributes that these elements would accept, and I was not able to determine this).
3. Although the approach I have taken appears to be very straightforward, is there any fundamental errors made that I have missed?

Any help would be appreciated, as I am trying to view the sql generated from linq queries in the code, and from what I understand, Linqpad5 is among the best developer tools out there for this purpose. Thank you in advance.
- Matt

Comments

  • Options
    edited August 2017
    Hi,

    Thanks a lot for showing me this far. I think I can help you move further.

    Just enter System.Data.Entity.DbContext in the field "full type name of typed DBContext" and provide the connection string. Just click test, and it should say successful. But I'm unable to move further.

    All the best!
Sign In or Register to comment.