4

I'm using EntityFramework but in some cases I get this Exception:

threw an exception.", inner exception: "Method not found: 'Void System.Data.Entity.DbModelBuilder.RegisterEntityType(System.Type)'.

Why is this exception is happening?

As I found out, this exception is happening when system expected to have EF 6.1.3, but the referenced EF is 6.0.0. As I updated my EF via nuget, it worked. The problem is in some cases I can not found any 6.0.0

For example I'm using a 3rd party component (XAF) which have a designer in Visual Studio. The designer cannot load because of this exception. The EF in my project is 6.1.3 but I don't know how it uses 6.0.0

Question 1: Why and when is this exception happening?

2 Answers 2

5

This exception probably is happening because of the different versions of loaded assemblies. If XAF referencies the 6.0.0 version in it's metadata, and your project doesn't, the compiler will load the 6.0.0 version to bin folder.

You can try overload the assembly version in you application configuration file (app.config), using something like this:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0-6.0.0" newVersion="6.1.3" />
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>
Sign up to request clarification or add additional context in comments.

Comments

0

I had same problem and change version of EF in all app.config and web.config files to correct version. like this in app.config of my DataLayer prject:

  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.1.3.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>

and also manage my NuGet packages to all of projects use same version.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.