9

我在 .cs 文件中有下面的代码,我遇到了下面的错误,任何帮助将不胜感激。

using System.Data.Entity;

namespace Assignment2.Models
{
    public class TicketBookingEntities : DbContext
    {
        public DbSet<Performance> Performances { get; set; }
        public DbSet<Production> Productions { get; set; }
    }
}

错误:

Error   1   The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
Error   2   The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
Error   3   The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?)
Error   4   The type or namespace name 'DbSet' could not be found (are you missing a using directive or an assembly reference?)
4

2 回答 2

16

确保您的项目包含对EntityFramework.dll的引用。如果您不知道如何添加引用,请参阅此链接
中 的主题在 Visual C#中添加引用。

于 2012-04-13T12:37:31.943 回答
2

尝试在对象浏览器中查找您丢失的引用。

于 2012-04-13T12:39:30.563 回答