adding DbContext connection throws error

When attempting to add a DbContext connection (EF 5), after I browse to the assembly, LinqPad shows
Could not load file or assembly 'EntityFramework, Version= one of its dependencies. The system cannot find the file specified
I am not sure why it's looking for 4.1, when the 5.0 assembly is referenced and in the same folder as the DbContext assembly.

I am using LinqPad 4.44.09


  • does the LinqPad team answer questions on this forum? Do I have to mention I own a license to get a response?
  • Sorry about the wait. I've been unable to reproduce your problem, but I've made some changes in beta I've released today which should at least generate a better error message. The error that you're getting is misleading in that LINQPad tries to load EF v4.1 from the GAC when it's either unable to determine which version of EF you're using, or it can't find the EntityFramework library.

    Try the latest beta (4.45.4) and let me know what happens.
  • I'm also seeing this. I use EF5 (via NuGet) with LinqPad 4.43, but also just tried LinqPad 4.45.05. I'm also wondering where LinqPad is trying to look for EF to begin with.
  • LINQPad looks for EntityFramework.dll in the same folder as the typed data context assembly. If it's not there, it looks in the GAC.
  • Thank you for the information - then I believe it should work, the EF dll is always in the same directory, but it doesn't. Is there any more information I should provide?
  • Are you using the latest beta?
  • I tried LinqPad 4.45.05 as I wrote some comments earlier. Should I try again with another beta?
  • Sorry for my delayed answers, but I don't know how to get email notifications.
  • Does 4.45.05 still give you the exact message "Could not load file or assembly 'EntityFramework, Version="?

    I would expect it to display something different if it fails... can you double check?
  • I just reinstalled the version (now no longer beta) and got the same message: "Could not load file or assembly 'EntityFramework, Version=,[...] or one of it's dependencies."

    I clicked on "About" to check that I'm running the new version of LinqPad.

    Also, the selected dll is using EF5, and the respective EF5 EntityFramework.dll is in the same path.
  • If you load that assembly in Reflector or ildasm, does it show a dependency on EntityFramework 5.0 or 4.1?
  • The dll's MANIFEST contains

    .assembly extern EntityFramework
    .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
    .ver 5:0:0:0
    as the second entry.
  • I wouldn't rule out that I'm doing something stupid - it wouldn't be the first time. But I don't think I am.
  • Is it possible you have referenced some other dll that requires EntityFramework, Version=, either in the Plugins folder or the Query Properties (F4) ?
  • I don't have a plugin folder. Also, how can a query interfere with the creation of a connection? You create the query in the connection, not the other way round. Still, I had a virgin query focused while trying to create the connection.
  • I take it there are no assembly redirections in your application config file or machine.config?
  • I indeed had this snippet in my web.config:

    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
    <bindingRedirect oldVersion="" newVersion="" />
    I think it got there from the EF package.

    However, commenting it out had no effect. I'm wondering why any of that would at all be used by LinqPad, web.config isn't even in the same path as the dlls.
  • Do you get the error if you create a fresh project and build an EF context for AdventureWorks or northwind?

    And is anyone else experiencing this problem?
  • Interesting, this worked. I had the ef power tools reverse engineer AdventureWorks in a new web project and the dialog created the connection this time.

    I wonder what's different between the projects. So far, I can't see anything, but at least I have a reference point now.
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!