Entity Framework from scratch Part 4 EF4 Multi Layered – System.Data.Entity not referenced

As i mentioned in the previous post, there seems to be a problem when you work with Multi layered Solutions in the Entity Framework. You need to add the Entity references to all the solutions in your project, but i found another small problem when creating a web front to your application.
I’ve built this app with EF4 features with web functionality.

When i debug my code, the database connection works and the table rows are fetched, but my webpage displays an compilation error: CS0012: The type ‘System.Data.Objects.DataClasses.EntityObject’ is defined in an assembly that is not referenced. You must add a reference assembly to ‘System.Data.Entity, version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’.

You need to add extra code manualy to your Web.config file directly under the system.web

[csharp]<configuration>
<system.web>[/csharp]

copy/paste the following code:

[csharp]
<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.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
[/csharp]

If you built and re-run the the app, the webpage is displayed correctly.

4 Replies to “Entity Framework from scratch Part 4 EF4 Multi Layered – System.Data.Entity not referenced”

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: