1

I'm using VS2012 and I've done something to break my EntityFramework configuration. The setup and EDMX were working correctly for some time using EF5.

Later I upgraded to EF6 and at that point was forced to make a handful of manual namespace changes to generated code each time I updated the model. But it still worked.

Now I am attempting to eliminate the problem which requires me to change the namespaces each time, but I've broken something.

Currently I cannot generate a DB first EDMX model at all. When I attempt this the wizard proceeds through the steps and then throws an error -- first a dialog about a null reference 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 have removed EF and reinstalled EF6 with NUGET. I have also tried this in a newly created project with the same result.

Google searches have not been fruitful. Any ideas?

Currently installed version of EF is 6.1.0

9
  • What database are you trying to talk to? Commented Apr 4, 2014 at 22:09
  • Did you install the correct tools for EF 6 in VS 2012? microsoft.com/en-us/download/details.aspx?id=40762 If yes try a repair install. Commented Apr 4, 2014 at 22:16
  • @RandRandom -- the tools for vs2012 and 6.1.0 were already installed. I ran a REPAIR install and sadly the behavior has not changed. Commented Apr 4, 2014 at 22:36
  • @DavidTansey - I think the NullRefException might be a key here. There was a bug in EF6.1 that caused tooling to fail (entityframework.codeplex.com/workitem/2126) but I am not sure if is the issue here. Does it still throw if you restart VS start a new project and try to create a new model for existing database (ideally a different one than the one you see errors with)? Commented Apr 4, 2014 at 22:43
  • Wow..Restart VS, new project and solution, choose a different DB (a very simple one) and generate -- no change. I'm going to look at that tooling-problem link now. Thanks for your attempt to help. Commented Apr 4, 2014 at 22:52

4 Answers 4

1

Also tried Visual Studio 2013 with entity framework tools 6.1.1 the same error you speak of persists and you can not create DB first EDMX model. The right solution is to submit a bug report to the Visual Studio team meanwhile uninstall entity framework tools 6.1 versions and install 6.0.1 which will work. EF tools 6.0.1 can be found in your installation media as EFTools in the packages folder.

P.S. Also when you repaired the VS2012 you were actually re-installing EFTools 6.0.1 and removing 6.1.0/6.1.1. You broke up your configuration in the first place by inadvertently updating EF Tools without realizing!

Sign up to request clarification or add additional context in comments.

Comments

0

I was ultimately able to resolve this issue by doing a REPAIR install of VS2012. After the REPAIR install and a reboot I am again able to generate EDMX models.

Comments

0

Entity framework tools 6.1.1 is not working mostly likely if you updated the original 2013 RTM version.It has probably corrupted registry entries. I downloaded the full 6 GB version and installed on a fresh operating system that has never had visual studio, voila it works!

Comments

0

Try this to fix the problem:

If you use VS2013, then go to:

C:\ProgramData\Package Cache{08AEF86A-1956-4846-B906-B01350E96E30}v12.0.20912.0\packages\EFTools, select the EFTools.msi file, and double-click it to install. This reinstall may solve your problem.

If you use VS2015, then go to:

C:\ProgramData\Package Cache{2A56910C-69C8-495D-8ED8-9080F0A14E58}v14.0.41103.0\packages\EFTools, select the EFTools.msi file, and double click it to install. This reinstall may solve your problem.

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.