CS0012: The type ‘System.Data.Spatial.DbGeography’ in Entity Framework and MVC

Last night I was working on a MVC4 project.  Utilizing Entity Framework 5’s new DBGeography when adding the field to the MVC view I received the following error:

Compiler Error Message: CS0012: The type 'System.Data.Spatial.DbGeography' 
is defined in an assembly that is not referenced. You must add a reference to 
assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089'.

To solve this an assembly reference needs to be added to the <system.web>  in /View/Web.config.  It should look like this.

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

Restart the solution and things should be good.

Advertisements
This entry was posted in Entity Framework, MVC and tagged , . Bookmark the permalink.

One Response to CS0012: The type ‘System.Data.Spatial.DbGeography’ in Entity Framework and MVC

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s