Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.Net MVC 3 & System.Data.Entity?

I'm creating my first asp.net MVC website(the version 3).

I'm using Entity Framework to get data from my database, so for now, I've a movies list in my database.

I'm trying to do a page which display the list of these movies.

So, the controller seems to be OK, it returns a View(IEnumerable).

In the view, I specified the type of my model:

@model IEnumerable

Movie is a class generated with a T4 template from my edmx, so it is heriting from EntityObject.

Now, when I try to display my page, I'm getting an error, indicating me that I've to import System.Data.Entity:

Server Error in '/' Application.

Compilation Error

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0012: Le type 'System.Data.Objects.DataClasses.EntityObject' est défini dans un assembly qui n'est pas référencé. Vous devez ajouter une référence à l'assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

Source Error:

Line 27: Line 28: Line 29:
public class _Page_Views_Movie_List_cshtml : System.Web.Mvc.WebViewPage> { Line 30: Line 31: #line hidden

Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\93402ec0\8f8e48f4\App_Web_list.cshtml.9612c299.pwpwk-k5.0.cs Line: 29

But, I've referenced this dll in my project and i've the corresponding using in my controller.

I tried to put this using in the cshtml: @using System.Data.Entity but it doesn't compile with(cannot find Entity in System.Data)

So what should I do?

all my projects are .Net 4(not the client profile)

like image 630
J4N Avatar asked May 06 '11 14:05

J4N


People also ask

What is Microsoft ASP.NET MVC 3?

ASP.NET MVC 3 is a framework for building scalable, standards-based web applications using well-established design patterns and the power of ASP.NET and the . NET Framework. It installs side-by-side with ASP.NET MVC 2, so get started using it today!

Is ASP.NET MVC still used?

ASP.NET MVC is no longer in active development.

Is ASP.NET MVC 5?

ASP.NET MVC 5 is a web framework based on Model-View-Controller (MVC) architecture. Developers can build dynamic web applications using ASP.NET MVC framework that enables a clean separation of concerns, fast development, and TDD friendly.


1 Answers

add the following line to your web.config

<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
like image 96
David Avatar answered Sep 22 '22 13:09

David