sisdog
sisdog

Reputation: 2719

LINQPad Query Error

Problem: Can't properly setup LINQPad connection to my Entity Framework dll.

  1. I downloaded LINQPad (v4.42.01)
  2. I started to create a new connection using the Entity Framework DbContext POCO driver
  3. At the setup dialog I pointed to my C# project's dll and it found the appropriate DbContext class.
  4. Next I pointed the config file to the app.config of my C# project
  5. When I hit the Test Button I get this error:

Error: The type initializer for 'System.Data.Entity.Internal.AppConfig' thre an exception. An error occurred creating the configuration section handler for entityFramework: Could not load file or assembly 'EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' on one of its dependencies. The system cannot find the file specified. (C:\Code\NET\FTI_Opp_Model\App.Config line 5)

So I tried doing what @Sorax did in this related question and moved my EntityFramework.dll from the one I got from NuGet in my project into the LINQPad.exe folder. This got me a little further along and the Test now worked. I was encouraged because my connection in the LINQPad panel showed all my entities underneath it.

But when I right click on my Borrower entity and chose "Borrower.Take(100)" I received this error from LINQPad:

The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.

With an inner exception message:

[A]System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection cannot be cast to [B]System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection. Type A originates from 'EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'Default' at location 'C:\MarkSisson\LinqPad\EntityFramework.dll'. Type B originates from 'EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' in the context 'LoadFrom' at location 'C:\Users\msisson\AppData\Local\Temp\LINQPad\vlnebssu\shadow_ujjvzp\EntityFramework.dll'.

Any ideas?

Upvotes: 3

Views: 1438

Answers (2)

Ran Davidovitz
Ran Davidovitz

Reputation: 1250

Btw the important thing to understand that the type of the assembly also include WHERE IT WAS LOADED.

meaning two same assemblies loaded from different location are not the same type!

Upvotes: 0

Joe Albahari
Joe Albahari

Reputation: 30934

Download the latest beta - this problem was fixed in 4.42.05.

Upvotes: 4

Related Questions