首页 > 解决方案 > using 语句中使用的类型必须可显式转换为“System.IDisposable”

问题描述

在现有数据库上使用 Entity Framework 和 Devart Entity Developer。我使用向导将所需的表带入实体设计器模型。保存模型 - 为 EF 创建底层代码。现在当我尝试使用:

using (Document ctx = new Document())
{

}

我得到错误:

CS1674 'Document':在 using 语句中使用的类型必须隐式转换为 'System.IDisposable' 或实现合适的 'Dispose' 方法。

我已经看到建议该状态以确保将实体框架添加为 NuGet 包的帖子 - 确实如此。我以前在这种情况下使用过实体设计器,但没有遇到这个问题。

有任何想法吗?

编辑

文档:

public partial class Document : EntityObject    {//...

实体对象:

namespace System.Data.Entity.Core.Objects.DataClasses
{
  /// <summary>
  /// This is the class is the basis for all perscribed EntityObject classes.
  /// </summary>
  [DataContract(IsReference = true)]
  [Serializable]
  public abstract class EntityObject : StructuralObject, IEntityWithKey, IEntityWithChangeTracker, IEntityWithRelationships
  {

标签: entity-framework-6devart

解决方案


推荐阅读