Hello all,
Im working on ASP.Net MVC app, wtih Entity Framework added in a class library. I added refrence of class library project (i.e ADO.Net Entity data model) into my ASP.Net MVC project.
And in when i try to access Entity in controller's action as shown below
- public ActionResult getProductDetails()
- {
- using (SampleTrialEntities entity = new SampleTrialEntities())
- {
-
- }
- return View();
- }
Here line #3 'using' shows the following error -
Error 1 'DataAccessLibrary.SampleTrialEntities': type used in a using statement must be implicitly convertible to 'System.IDisposable'
Error 2 The type 'System.Data.Entity.DbContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
But when I add ADO.Net Entity data model in ASP.Net MVC project, it works as expected.
So, Should I add ADO.Net Entity data model only in the project in which it is used.? can't I have a separate DAL for this EF and use it in other projects?
Can anyone help me, your response is appreciated.