- | rssFeed | My book on MSBuild and Team Build | Archives and Categories Thursday, 23 April 2009

ASP.NET MVC: Using Entity Objects in Views

If you are you using ASP.NET MVC and the Entity Framework then odds are that you will want to use some of your entity object inside of your views. If you've tried this you may have run into the following exception: "CS0234: The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)".


So the first guess is to add a reference to System.Data.Entity assembly in the MVC project. I did that then ran my app again, and I encountered the same error. After some poking around I figured out that you need to manually add the assembly to the web.config file. So in your web.config file you need to add the element

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

Under the compiliation\assembiles node, here it is:

Once you've done this you should be able to run your app with no problems.

 

Sayed Ibrahim Hashimi

ASP.NET MVC | Entity Framework Thursday, 23 April 2009 19:18:20 (GMT Daylight Time, UTC+01:00)  #     |