views:

328

answers:

4

Hi everybody,

In VS 2010, changing true 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 compile!

Any ideas? Thanks.

A: 

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"&gt;
  <PropertyGroup>
    ...BLAH...
    <BaseIntermediateOutputPath>..\TempBuildOutput</BaseIntermediateOutputPath>
  </PropertyGroup>
  ...A WHOLE LOTTA BLAH...
</Project>

HTHs,
Charles

Charlino
+6  A: 

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.

AndrewDotHay
Obvious and logical solution. Thanks. But why is thid behaving like that? Why am I need to add System.Data.Entity.Design namespace to my assembly, it's nothing to do with my code. I Visual Studio's job, it shouldn't be added to my application.
Alper Ozcetin
A: 

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>
Mark
+2  A: 

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!

benpage
This ended up being my problem, something had been accidentally dragged and dropped into the wrong folder.
Falkayn
just figured this out in mine. old replaced edmx was getting picked by the compiler for some @#$@#$ reason.
boomhauer