Question

I've read that Self-Tracking Entities (STE) are now deprecated and Microsoft will not invest in those anymore.

I am currently working on a n-tier application in which client code is making method calls to a WCF Service to fetch Self-Tracking Entities. There is no such thing as a DBContext in my client code : it only deals with the entities themselves.

Since a self-tracking entity has it's change tracker code within itself, the client code can easliy work with them and it's easy to actually push the changes back into the database.

I've tried the EF4 DBContext Generator t4 templates but they generate persistence-ignorant entities, therefore, my client code cannot work with them to track the changes the way it did with STEs.

Is it possible to migrate from such a project to a DBContext based project without having to rewrite a big deal of client code as well as the WCF Service code ?

Was it helpful?

Solution

There is STE Generator template for EF 5.x and its information page says:

We no longer recommend using the STE template in new applications, it continues to be available to support existing applications. Visit the N-Tier Applications page for other options we recommend for N-Tier scenarios.

That answers your question. If you want to use STEs without rewriting your application you should use the template and ObjectContext. In theory you can use DbContext because you can create a new instance of the DbContext from existing ObjectContext (through the constructor). I'm not sure what benefit it will have with STEs.

MS considers WCF Data Services and their client context as replacement for STEs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top