ASP.NET MVC View Error — Could not load file or assembly ‘System.Data.Entity’ or one of its dependencies.

Today I kept getting this error in my Razor View. The error message said,

Could not load file or assembly ‘System.Data.Entity, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified

Solution :

To use an external Entity Framework model, (for example : embedded in a dll as a reference) with ASP.NET MVC 3/4 you must :

  • Add the following reference to your MVC project : System.Data.Entity (Version, Runtime v4.0.30319)
  • Add the following line in your web.config


<compilation debug="true" targetFramework="4.0">  
<add assembly="System.Data.Entity, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" />

This solved my problem. Hope it does yours too. Cheers !