Questions tagged [self-tracking-entities]

In an Entity Framework-based application, a context is responsible for tracking changes in your objects. Self-Tracking Entities (STEs) can help you track changes in any tier and then replay these changes into a context to be saved.

In an Entity Framework-based application, a context is responsible for tracking changes in your objects. You then use the SaveChanges method to persist the changes to the database. When working with N-Tier applications, the entity objects are usually disconnected from the context and you must decide how to track changes and report those changes back to the context.

Self-Tracking Entities (STEs) can help you track changes in any tier and then replay these changes into a context to be saved.

WARNING: STEs are no longer recommended.

More Info

173 questions
40
votes
2 answers

What is the purpose of self tracking entities?

I've been reading about self-tracking entities in .net and how they can be generated from a *.edmx file. The thing that I'm struggling to understand is what generating these entities gives you over the basic EF entities? Also, some people have…
Calanus
  • 23,416
  • 24
  • 77
  • 118
31
votes
4 answers

Self Tracking Entities vs POCO Entities

We are starting a new web based product in which we are planning to expose our business logic through WCF services. We will be using ASP.NET 4.0, C#, EF 4.0. In future we want to build iphone applications and WPF applications based on the services.…
Kumar
  • 2,713
  • 11
  • 41
  • 59
22
votes
8 answers

Asynchronously Lazy-Loading Navigation Properties of detached Self-Tracking Entities through a WCF service?

I have a WCF client which passes Self-Tracking Entities to a WPF application built with MVVM. The application itself has a dynamic interface. Users can select which objects they want visible in their Work area depending on what role they are in or…
Rachel
  • 122,023
  • 59
  • 287
  • 465
18
votes
2 answers

Entity Framework Self-Tracking Entities not recommended by Microsoft

While looking at Microsoft's web site, I discovered that they no longer recommend using Self-Tracking Entities. Each link below is a MS resource that mentions not to use STEs: Shows what templates are available by the Entity Framework team: EF…
13
votes
1 answer

Entity Framework Split Table Delete

I'm using EF 4 STE's to model an Attachment object. The Attachment contains a Name, Description, Date, and most importantly Data (byte[]). To optimize loading, I don't want to retrieve the Data property until it's absolutely necessary, i.e. when the…
12
votes
2 answers

Why is entity still validated when it is gone?

Add a new entity to a TrackableCollection (context.Entities.Add(entity)) (EntityState = New) Without saving, delete the added entity from TrackableCollection (context.Entities.Remove(entity)) (EntityState = Unmodified) Save.…
O.O
  • 10,083
  • 18
  • 83
  • 166
12
votes
5 answers

Self Tracking Entities - AcceptChanges cannot continue because the object's key values conflict with another object in the ObjectStateManager

I've been stuck with this problem for over a week now. Hopefully some one can point me in the right direction. I start with a brief description of my schema. Asset 1--->1 Address *-->1 Area *-->1 Region *-->1 Country Package 1-->* Asset Using Self…
Tri Q Tran
  • 5,010
  • 2
  • 31
  • 58
12
votes
2 answers

EF4 POCO: Snapshot vs Self-tracking over WCF

Last year I developed a data access service for our project using Entity Framework (.NET3.5 of course) and using Julie Lerhman's book as a guide developed state tracking POCO objects. We use WCF and also have Silverlight 3 clients. We are moving to…
MrLane
  • 1,698
  • 22
  • 40
11
votes
2 answers

Using the lambda Include method in a compiled LINQ query

I'm currently trying to optimize some of the LINQ queries in my program by precompiling them. Some of these queries make extensive use of eager loading; here's an example of one: public static Func>…
10
votes
1 answer

What are essential differences between the different code generation items for EDMX model?

I'm trying to ramp up on the entity framework so I don't feel like I'm in the dark ages. I tried (and have thus far failed) to intuit from generated code what the essential differences between the available code generation items. It seems POCO…
Aaron Anodide
  • 16,154
  • 14
  • 59
  • 117
8
votes
3 answers

How would I know if I should use Self-Tracking Entities or DTOs/POCOs?

What are some questions I can ask myself about our design to identify if we should use DTOs or Self-Tracking Entities in our application? Here's some things I know of to take into consideration: We have a standard n-tier application with a WPF/MVVM…
Rachel
  • 122,023
  • 59
  • 287
  • 465
7
votes
1 answer

How do I get Entity Framework to only update the Properties modified in the SQL generated?

I am using Entity Framework with the Self-Tracking Entity T4 templates, which by default will generate a SQL Query setting all the properties on the Entity in an UPDATE statement. I only want an UPDATE statement that contains the properties…
7
votes
2 answers

Are nullable foreign keys allowed in Entity Framework 4?

I have a problem updating a foreign key in an Entity Framework entity. I am using self tracking entities and have an entity with some relations where the foreign key is also present as a property (one of the new features of EF4). The key (an…
6
votes
1 answer

Difference between a Repository Implementation using ObjectContext vs DbContext on EF 4.1

What could be the better implementation for STE, I heard about that DbContext is the simplest way to implement a Repo with EF, personally I take advantage of the EntityState, but there is any member on ObjectContext that could deliver more…
6
votes
2 answers

Many queries and too much opening / closing of the same connection

I have to recalculate values on a large collection of entities, one after the other. During that process, all the self-tracking-entities are altered within the same ObjectContext. For each entity that needs to be processed, small amounts of data has…
user2324540
1
2 3
11 12