I am trying to initialize the EFUnitOfWorkFactory object context.
In global.asax:
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
ObjectFactory.Initialize(x =>
{
x.For<IUnitOfWorkFactory>().Use<EFUnitOfWorkFactory>();
x.For(typeof(IRepository<>)).Use(typeof(EFRepository<>));
}
);
EFUnitOfWorkFactory.SetObjectContext(() => new MyEntities());
}
In the generated Object context I have:
public partial class MyEntities : ObjectContext
{
.....
.....
}
I get an exception when I execute the web application in EFUnitOfWorkFactory.SetObjectContext(() => new MyEntities());
:
Compiler Error Message: CS0012: The type 'System.Data.Objects.ObjectContext' 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'.
I added System.Data.Entity to my web application twice and rebuild but I still get this message. In addition, this line in the gobal.asax smetimes marked with red underline.
Does anyone knows how to solve this?