IDisposable.Dispose 在其他程序集中尝试使用 class 时不可用

IDisposable.Dispose is not available when trying to use a class in other assembly

我有一个名为 DataWare 的数据访问 class 库。在里面我有这样定义的上下文 class:

namespace DataWare
{
    using System;
    using System.Data.Entity;
    using System.Data.Entity.Infrastructure;

    public partial class GestionCasinoEntities : DbContext
    {
        public GestionCasinoEntities()
            : base("name=GestionCasinoEntities")
        {
        }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            throw new UnintentionalCodeFirstException();
        }

        public DbSet<Auditoria> Auditoria { get; set; }
        public DbSet<CentroCosto> CentroCosto { get; set; }
        public DbSet<Contingencia> Contingencia { get; set; }
        public DbSet<Departamento> Departamento { get; set; }
        public DbSet<Empresa> Empresa { get; set; }
        public DbSet<Equipo> Equipo { get; set; }
        public DbSet<Funcionario> Funcionario { get; set; }
        public DbSet<GrupoParametro> GrupoParametro { get; set; }
        public DbSet<GrupoServicio> GrupoServicio { get; set; }
        public DbSet<Marcacion> Marcacion { get; set; }
        public DbSet<Modulo> Modulo { get; set; }
        public DbSet<Pais> Pais { get; set; }
        public DbSet<Parametro> Parametro { get; set; }
        public DbSet<Semana> Semana { get; set; }
        public DbSet<Servicio> Servicio { get; set; }
        public DbSet<Turno> Turno { get; set; }
        public DbSet<UbicacionEquipo> UbicacionEquipo { get; set; }
    }
}

问题是当我尝试从其他程序集使用 class 时,只有 DbSet 属性可用,而 Dispose 方法不可用。所以,我不能这样做:

            using (GestionCasinoEntities db = new GestionCasinoEntities())
            {
            }

这里可能发生了什么?

如果在我编写的 GestionCasinoEntities 代码中 this.Dispose,智能感知显示它可用,但是,当我尝试在另一个程序集中对 db.Dispose 执行相同操作时,Dispose 不可用。可能缺少一些参考。

Fede 的评论作为社区维基答案发布。如果 Fede 发布了他自己的答案,请删除。

联邦调查局说:

Is GestionCasinoEntities class defined in a different assembly than the one trying to use it? If that's the case, you'll also need to add a reference EntityFramework.dll to the referring project, though the compiler should have warned you about that already.