Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dynamic Data IObjectContextAdapter missing reference

I have a fresh install of VS2012 with Update 2. I create a new project of "ASP.NET Dynamic Data Entities Web Application". I then add an "ADO.NET Entity Data Model" which I generate from an existing SQLServerExpress database.

However when I go to build the solution i get the following error:

The type or namespace name 'IObjectContextAdapter' could not be found (are you missing a using directive or an assembly reference?)

That appears to be declared in System.Data.Entity.Infrastructure but I cannot find that assembly anywhere. I have verified that I have EF5 is installed for the solution as my packages.config shows:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="EntityFramework" version="5.0.0" targetFramework="net45" />
</packages>

The EntityFramework reference properties shows:

RuntimeVersion: v4.0.30319
Version: 5.0.0.0

and in web.config I have:

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

This looks wrong as it should say 5.0.0.0? However changing it has no effect whatsoever. Can someone please point me in the right direction?

like image 773
TheEdge Avatar asked Apr 22 '13 11:04

TheEdge


2 Answers

Getting this to compile turned out to be very easy. I needed to add:

using System.Data.Entity.Infrastructure;

to Global.asax.cs. Seems that the T4 template does not include this be default.

like image 192
TheEdge Avatar answered Oct 20 '22 03:10

TheEdge


<%@ Import Namespace="System.Data.Entity.Infrastructure" %>

adding this line to the top of the global.asax works as well.

like image 32
hanzolo Avatar answered Oct 20 '22 05:10

hanzolo