【问题标题】:ObjectSet library is not being found?没有找到 ObjectSet 库?
【发布时间】:2011-01-24 20:54:07
【问题描述】:
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。有人有什么好主意吗?

【问题讨论】:

    标签: asp.net-mvc-2 asp.net-4.0 objectset


    【解决方案1】:

    确保您的项目引用了System.Data.Entity

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

    当您将 EDMX 文件(ADO.NET 实体数据模型)添加到您的项目时,Visual Studio 会自动为您添加这些。

    【讨论】:

    • 知道了..由于某种原因使用.net 3.5..我的错误:(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-27
    • 2011-08-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-07
    • 1970-01-01
    相关资源
    最近更新 更多