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

admdrew
  • 3,790
  • 4
  • 27
  • 39
David Tansey
  • 5,813
  • 4
  • 35
  • 51
  • What database are you trying to talk to? – Pawel Apr 04 '14 at 22:09
  • Did you install the correct tools for EF 6 in VS 2012? http://www.microsoft.com/en-us/download/details.aspx?id=40762 If yes try a repair install. – Rand Random Apr 04 '14 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. – David Tansey Apr 04 '14 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 (https://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)? – Pawel Apr 04 '14 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. – David Tansey Apr 04 '14 at 22:52
  • Because you see this even with a new database/project this feels like an installation/machine issue. I don't know how far you can go with troubleshooting it but you may try debugging EF Tools. I wrote instructions steps here https://entityframework.codeplex.com/wikipage?title=Debugging%20EF%20Tools without a stack trace for the initial NRE and more details for the TypeLoadException it is very hard to tell what's happening. The only thing that comes to my mind - make sure that you have EntityFramework.dll in Common7\IDE (this is a private version EF Designer uses installed with the designer) – Pawel Apr 04 '14 at 22:58
  • @pawel - I have EntityFramework.dll 6.1.30225 in folder C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE – David Tansey Apr 04 '14 at 23:40
  • @pawel - Aside from doing the debugging exercise with EF tools (which you seem to have nicely documented) what are my options? Reinstall VS2012? Seems like a bit much. – David Tansey Apr 05 '14 at 00:02
  • Ef designer is a separate msi so you can uninstall it from programs and features and install again (I don't trust repair too much) – Pawel Apr 05 '14 at 14:59

4 Answers4

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!

Robert Omete
  • 64
  • 1
  • 10
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.

David Tansey
  • 5,813
  • 4
  • 35
  • 51
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!

Robert Omete
  • 64
  • 1
  • 10
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.

Farb
  • 468
  • 6
  • 11