TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
L A
NA
170
171.1k
Accessing Entity - Error (Entity Framework)
Oct 24 2017 11:31 PM
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())
{
// call entity operation
}
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.
Reply
Answers (
2
)
Add icon next to leafnode of asp Tree view
how to do crude operation in asp.net core 2.0