1

Using Entity Framework and Devart Entity Developer on an existing database. I brought the table needed into the Entity Designer model using the wizard. Saved the model - that creates the underlying code for EF. Now when I try to use:

using (Document ctx = new Document())
{

}

I get the error:

CS1674 'Document': type used in a using statement must be implicitly convertible to 'System.IDisposable' or implement a suitable 'Dispose' method.

I have seen posts that suggest that state to make sure that Entity Framework is added as a NuGet package - it is. I have use Entity Designer before in this situation but did not run into this issue.

Any ideas?

Edit

Document:

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

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
  {
Eric Snyder
  • 1,816
  • 3
  • 22
  • 46
  • Of what type is `Document`? That does not look like a context unless it is a devart class that inherits. – Steve Greene Apr 30 '19 at 20:20
  • Document is a table named Document in the database. – Eric Snyder Apr 30 '19 at 21:14
  • @Steve Green: I did check another app that I used this from. The table objects inherit from ObjectContext rather than EntityObject – Eric Snyder Apr 30 '19 at 21:24
  • Where are you expecting the `IDisposable` implementation to come from? `EntityObject` doesn't implement it and it doesn't look like `Document` does either. – Lee Apr 30 '19 at 21:46
  • 1
    You don't `use` a table - you `use` the context and then access the table like `context.Documents`. – Steve Greene Apr 30 '19 at 22:21
  • Please send us a small test project for reproducing the error in our environment: https://www.devart.com/company/contactform.html. – Devart May 01 '19 at 10:43
  • @Steve Greene - You are correct. That was the issue - operator error. Thank you. – Eric Snyder May 01 '19 at 13:21

0 Answers0