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
<configuration> <system.web>
copy/paste the following code:
<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>
If you built and re-run the the app, the webpage is displayed correctly.
another simply way is to add reference “system.data.entity” AND make sure, in it’s properties, “copy local” set to true.
It didn’t work at first, but now the reference seems to work. thanks for the comment! 😉
Helpful blog, bookmarked the website with hopes to read more!
Thanks, keep an eye out, we update the site regularly with more cool codesnippets and new technologies.