Tuesday, February 12, 2013

Type used in a using statement must be implicitly convertible to 'System.IDisposable'

I was recently working with an Entity Framework project in Visual Studio 2012 which I had created an ASP.NET Web Forms Application project and referenced a separate project containing my Entity Data Model Class Library (a C# Class Library project containing an ADO.NET Entity Data Model).

Unfortunately, after making a reference to my Entity Data Model Class Library, I got the following error message:

'MyNs.MyEntities': type used in a using statement must be implicitly convertible to 'System.IDisposable'

Try as I might, I could not figure out how to get rid of this error message by adding the various using statements to my class.

Finally, while working with a colleague of mine, we decided to compile the project and see if any error messages popped up that offered any additional insight as to the root cause of the error.

Fortunately, the compilation error message in Visual Studio indicated that I needed to add an Assembly Reference in my project to System.Data.Entity!!

After I added this project assembly reference, just like magic the error message finally vanished! Whew!....

No comments:

Post a Comment