using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using ModelLayer.PocoModels;
using System.Data.Objects;
namespace ModelLayer
{
public class NorthwindDataContext : ObjectContext
{
private ObjectSet<Category> _categories;
private ObjectSet<Product> _products;
public NorthwindDataContext()
: base("name=NorthwindEntities",
"NorthwindEntities")
{
_categories = CreateObjectSet<Category>();
_products = CreateObjectSet<Product>();
}
}
}
在上面的代码中我得到一个错误,因为它找不到ObjectSet
类并给出类型或名称空间未找到错误。虽然在示例项目中它工作正常,但正在使用System.Data.Objects.ObjectSet
但我在当前项目中没有看到该库?我正在使用 asp.net mvc 和 .net 4.0。有人有什么好主意吗?
确保您的项目有参考System.Data.Entity
.
您可能还需要参考System.Runtime.Serialization
and System.Security
.
当您将 EDMX 文件(ADO.NET 实体数据模型)添加到项目时,Visual Studio 会自动为您添加这些内容。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)