EntityFramework cannot generate DB EDMX - null reference, cannot load type

I am using VS2012 and I did something to break my EntityFramework config. The setup and EDMX have been working correctly for some time using EF5.

I later upgraded to EF6 and at that point was forced to make a few manual namespace changes to the generated code every time I updated the model. But it still worked.

Now I am trying to fix an issue that requires me to change namespaces every time, but I broke something.

I am currently unable to create a basic EDMX model at all. When I try to do this, the wizard goes through the steps and then throws an error - first the null reference dialog and then in the VS output:

Unable to generate the model because of the following exception: 'System.TypeLoadException: Could not load type 'System.Data.Entity.Core.Mapping.EntityContainerMapping' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
    at Microsoft.Data.Entity.Design.VersioningFacade.ReverseEngineerDb.DbDatabaseMappingBuilder.Build(SimpleMappingContext mappingContext)
    at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelGenerator.GenerateModel(List`1 errors)
    at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModels(String storeModelNamespace, ModelBuilderSettings settings, List`1 errors)
    at Microsoft.Data.Entity.Design.VisualStudio.ModelWizard.Engine.ModelBuilderEngine.GenerateModel(ModelBuilderSettings settings, ModelBuilderEngineHostContext hostContext)'.

      

I uninstalled EF and reinstalled EF6 using NUGET. I also tried this on a new project with the same result.

Google searches have not been fruitful. Any ideas?

EF version 6.1.0 is currently installed

+1


source to share


4 answers


Also tried Visual Studio 2013 with Entity Infrastructure Tools 6.1.1 the same error you are talking about persists and you cannot create a basic EDMX for the DB. The correct solution is to provide a bug report to the Visual Studio team, at the same time uninstall the 6.1 object framework tools, and install 6.0.1, which will work. EF 6.0.1 Tools can be found on the installation media as EFTools in the packages folder.



PS Also when you repaired VS2012 you actually rebooted EFTools 6.0.1 and uninstalled 6.1.0 / 6.1.1. First you crashed your config by unintentionally updating EF Tools without realizing!

+1


source


I was ultimately able to fix this issue by performing a REPAIR VS2012 installation. After installing REPAIR and rebooting, I will be able to generate EDMX models again.



0


source


The Object Infrastructure 6.1.1 tools don't work mostly if you've updated the original 2013 RTM version. These are likely corrupted registry entries. I downloaded the full 6GB version and installed a new operating system that never had visual studio, it works!

0


source


Try to fix the problem:

If you are using VS2013 go to:

C: \ ProgramData \ Package Cache {08AEF86A-1956-4846-B906-B01350E96E30} v12.0.20912.0 \ packages \ EFTools , select the file EFTools.msi

and double click on install. This reinstallation might fix your problem.

If you are using VS2015 go to:

C: \ ProgramData \ Package Cache {2A56910C-69C8-495D-8ED8-9080F0A14E58} v14.0.41103.0 \ packages \ EFTools , select the file EFTools.msi

and double click on install. This reinstallation might fix your problem.

0


source







All Articles