entity framework patten for asp.net; need get it back again to update? Keep objectContext in Applica

R

Ryan Liu

Hi,

What is recommended patten for using entity framework in asp.net?

I mean, seems to me little bit inefficient to update an entity, first need
get it from db.

Or is that very bad idea to keep the object context in applicaton scope and
reuse it among sessions and multiple requests? Of couse, need handle race
situlation and need make sure database and datacontext are in sync.

Then any one need modify an entiy, no need fetch from db first.

Thanks,
Ryan
 
M

Mr. Arnold

Ryan Liu said:
Hi,

What is recommended patten for using entity framework in asp.net?

By use of a WCF Web service using SOAP in a n-tier solution of
UI/BL/DAL/Model, since an EF entity is an implicit WCF Data Contract. Or
instaed of using WCF Web Service, one can use an ASP.NET Data Service using
ADO.NET Entity Framework on the backend with REST.
I mean, seems to me little bit inefficient to update an entity, first need
get it from db.

You're dealing with objects in a virtual database, and the object must be
instantiated and/or populated before one can use an object. Do you know what
Domain Driven Design and Test Driven Design are about, along with MVC or
MVP? Those are the patterns you should be following, as those are the
patterns that work against the virtual database 'model' with using
'objects' that are persisted to a database..
Or is that very bad idea to keep the object context in applicaton scope
and reuse it among sessions and multiple requests? Of couse, need handle
race situlation and need make sure database and datacontext are in sync.

What are you talking about? I suggest you get a good book on the subject of
implementing solutions using the ADO.NET Entity Framework, particularly Web
based solutions.

If you're going to keep objects in session then you need to keep a DTO -
Data Transfer Object in session and/or a Business Object in session, not an
EF entity. Anyone that can hack the solution would have complete access to
the Entity and act upon the its properties and or methods.
Then any one need modify an entiy, no need fetch from db first.

A completely none secure ASP.NET solution is what you're looking to
implement, using the ADO.NET Entity Framework.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top