34
votes

In VS 2010, changing <MvcBuildViews>true</MvcBuildViews> in a MVC2 project's .csproj file causes an error if you are using Entity Framework.

Could not load type 'System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider'. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config 129

I want to build views while I'm debugging, and I also want my project to compile!

6

6 Answers

60
votes

You can resolve this MVC compile issue by adding the following element to your web.config file:

<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

This will tell the compiler where to find that missing type.

5
votes

i had this problem too, and figured out that i had created some entity files (edmx and the like) but had deleted them.

this problem only started happening after i had created these files. on inspection of the application folders, i found that visual studio hadn't actually 'deleted' them off the drive, it had just 'deleted' them out of the project. therefore, when the project was being compiled, it saw this edmx file and decided it would include it. hence the error.

easy fix - permanently delete the entity files off the drive!

3
votes

Alternately you can remove the build provider.

<system.web>
  <compilation debug="true" targetFramework="4.0">
    <buildProviders>
      <remove extension=".edmx"/>
    </buildProviders>
  </compilation>
</system.web>
2
votes

This is an complete example web.config

<configuration>
<system.web>
    <customErrors mode="Off"/>
        <compilation debug="true" targetFramework="4.0">
 <assemblies>
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />       
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
    <add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
  </assemblies>
</compilation>
</system.web>
</configuration>
0
votes

I had a similar error when setting MvcBuildViews="true" which had to do with the build finding multiple web.configs due to build temp files and simply not liking it.

It's a totally different error, but I have a sneaky suspicion that they could be related...

You can find the original question I had here and then the solution outlined here.

The solution basically gets you to change where the output path is for you builds... so you need to add <BaseIntermediateOutputPath> to your website's csproj file.

E.g.

<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    ...BLAH...
    <BaseIntermediateOutputPath>..\TempBuildOutput</BaseIntermediateOutputPath>
  </PropertyGroup>
  ...A WHOLE LOTTA BLAH...
</Project>

HTHs,
Charles

0
votes

Not enough rep to add a comment. Wanted to mention that you need to add the 'System.Data.Entity.Design' assembly reference to the root Web.config. I was inadvertently trying to add it to a Web.config in my Views directory. Watch out for this pitfall.