Blog from Saravanan Arumugam

Let us talk about Technologies

‘__Entities’: type used in a using statement must be implicitly convertible to ‘System.IDisposable’


I have a solution where my working project references the project having the Entity Data Model. When I create the entity model context with the using statement I get the following compiler error.

Exception

Error 2 ‘Intrado.Data.MyEntities’: type used in a using statement must be implicitly convertible to ‘System.IDisposable’ C:\Saravanan\MyApp\MyApp.Service.cs 16 13 MyApp.Service

Solution

We can find this issue when the entity model is in a different project than the working project. We get this exception since the Compiler knows till the point that the entity class (MyEntities in my example) is derived from ObjectContext. For some reason C# compiler can’t understanding that ObjectContext has implemented the IDisposible.

To resolve it, simply add a reference to the System.Data.Entity in the working project. This should take care of this error.

Advertisements

5 responses to “‘__Entities’: type used in a using statement must be implicitly convertible to ‘System.IDisposable’

  1. Rinqu Moral March 31, 2012 at 11:54 pm

    Thanks It’s working to follow your post.

  2. tejaswi January 5, 2013 at 2:32 am

    still it gives that error only. plz solve my problem.

  3. MC May 28, 2013 at 5:14 am

    Try adding a reference to EntityFramework.dll in your project libs, worked for me.

  4. Vinh Vu June 21, 2013 at 9:32 am

    Works great fo rme

  5. Sanjay March 11, 2014 at 6:13 am

    after adding Reference also it’s not working.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: