ObjectSet library is not being found?
Asked Answered
G

1

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

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 ?

Guesswarp answered 24/1, 2011 at 20:54 Comment(0)
L
3

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

You may also need references to System.Runtime.Serialization and System.Security.

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

Ligialignaloes answered 24/1, 2011 at 20:58 Comment(1)
Got it..it was for some reason using .net 3.5..my bad :(Guesswarp

© 2022 - 2024 — McMap. All rights reserved.