我尝试使用Repository Design Pattern。我添加了一个类并编写了下面的代码。我想在存储库设计模式中使用实体框架。
型号:
public class Repository<T> where T : class
{
ObjectContext _context;
IObjectSet<T> _objectSet;
(AddObject,Attach,DeleteObject,Detach)
public Repository()
{
_context = new DTEntities(); // Problem here
_objectSet = _context.CreateObjectSet<T>();
}
public Repository(ObjectContext objectContext)
{
_context = objectContext;
_objectSet = _context.CreateObjectSet<T>();
}
}
错误:
new DTEntities(); says that,
Cannot implicitly convert type 'MyProject.Models.DtEntities' to ' System.DataObjects.ObjectContext'
如何隐式转换类型asp.net MVC?