none
Problem in Context class ASP.NET 4.5 RRS feed

  • Question

  • When i want to execute the following code

    using System.Data.Entity;
    namespace WingtipToys.Models
    {
       
    public class ProductContext : DbContext
       
    {
           
    public ProductContext() : base("WingtipToys")
           
    {
           
    }
           
    public DbSet<Category> Categories { get; set; }
           
    public DbSet<Product> Products { get; set; }
       
    }
    }

    I encounter the following problem :

    Error 1 The type 'System.Data.Objects.ObjectContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. F:\ASP.NET Practise\WingtipToys\WingtipToys\Models\ProductContext.cs 11 16 WingtipToys

    Please anyone help.

    Monday, January 28, 2013 5:08 AM

Answers

  • In some of your projects you don't have reference to the System.Data.Entity assembly that is used by the Entity Framework. Possibly the other project has reference to the assembly where ProductContext is, but it has no reference to the assembly in error message.
    Monday, January 28, 2013 6:40 AM