对象集库没有被发现? [英] ObjectSet library is not being found?

查看:171
本文介绍了对象集库没有被发现?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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>();
        }
    }
}

在上面的code我得到的,因为它不能找到对象集类,并给了我类型或命名空间找不到error.While示例项目中的错误它工作正常,这是在使用 System.Data.Objects.ObjectSet ,但我没有看到,在图书馆我当前的项目?我使用asp.net MVC和.NET 4.0。没有人有任何好的想法?

In the above code I get an error as it cant find the ObjectSet class and gives me type or namespace not found error.While in the sample project it works fine it is under using System.Data.Objects.ObjectSet but I dont see that library in my current project? I am using asp.net mvc and .net 4.0. Does anyone have any good ideas ?

推荐答案

请确保您的项目有一个参考 System.Data.Entity的

Make sure your project has a reference to System.Data.Entity.

您可能还需要引用 System.Runtime.Serialization System.Security

Visual Studio中会自动将这些对你,当你添加一个EDMX文件(ADO.NET实体数据模型)到项目中。

Visual Studio adds these for you automatically when you add an EDMX file (ADO.NET Entity Data Model) to your project.

这篇关于对象集库没有被发现?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆