I have following code
using (AdventureWorksEntities database = new AdventureWorksEntities())
But it is showing that
‘New_WCF_App1.AdventureWorksEntities’: type used in a using statement must be implicitly convertible to ‘System.IDisposable’
How to solve this
Well, the error message is reasonably clear –
AdventureWorksEntitiesdoesn’t implement theIDisposableinterface. It can’t be disposed, so you can’t use it as the resource in ausingstatement.Next you need to work out whether it should implement
IDisposable, or whether it really doesn’t have any resources to dispose.EDIT: According to comments, with Entity Framework 4 this should work without any extra implementation, as the auto-generated code already implements
IDiposable.