self-tracking-entities

Self Tracking Entities (STE)'s and partial updates with EF4 and mVC2

I have an MVC2 app where I am starting to use the STE's. I am looking for some clarification on how updates should work. Background: If I have a Blog entity with related category entities and Related post/comment entities. In MVC I am rendering a view with the main Blog entity and the categories but not the related posts. When I pos...

EF 4 Self Tracking Entities does not work as expected.

I am using EF4 Self Tracking Entities (VS2010 Beta 2 CTP 2 plus new T4 generator). But when I try to update entity information it does not update to database as expected. I setup 2 service calls. one for GetResource(int id) which return a resource object. the second call is SaveResource(Resource res); here is the code. public Resou...

EF4 POCO: Snapshot vs Self-tracking over WCF

Hello 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 .NET 4.0 and I want to switch to using code generation to eliminate wasted develope...

What is the proper way to handle non-tracking self tracking entities?

Self tracking entities. Awesome. Except when you do something like return Db.Users; none of the self-tracking entities are tracking (until, possibly, they are deserialized). Fine. So we have to recognize that there is a possibility that an entity returning to us does not have tracking enabled. Now what??? Things I have tried F...

Different EF Property DataType than Storage Layer Possible?

Hi, I am putting together a WCF Data Service for PatientEntities using Entity Framework. My solution needs to address these requirements: Property DateOfBirth of entity Patient is stored in SQL Server as string. It would be ideal if the entity class did not also use the "string" type but rather a DateTime type. (I would expect this t...

EF4, self tracking, repository pattern, SQL Server 2008 AND SQL Server Compact

Hi, I am creating a project using Entity Frameworks 4 and self tracking entities. I want to be able to either get the data from a sql server 2008 database or from sql server compact database (with the switch being in the config file). I am using the repository pattern and I will have the self tracking entities sitting in a separate ass...

Entity Frameworks 4 - Changing the model does not update the T4 self tracking template files

I am using self tracking entities and have moved the entity classes to another assembly by using 'Add as link' to point to the TT file as mentioned here. Now though, when I update the model (for instance change a property name) the template is not automatically run and so the entity class does not get updated. I can of course manually ...

Entity Framework - Foreign key constraints not added for inherited entity

Hello, It appears to me that a strange phenomenon is occurring with inherited entities (TPT) in EF4. I have three entities. 1. Asset 2. Property 3. Activity Property is a derived-type of Asset. Property has many activities (many-to-many) When modeling this in my EDMX, everything seems fine until I try to insert a new Property into th...

How to track deleted self-tracking entities in ObservableCollection without memory leaks

In our multi-tier business application we have ObservableCollections of Self-Tracking Entities that are returned from service calls. The idea is we want to be able to get entities, add, update and remove them from the collection client side, and then send these changes to the server side, where they will be persisted to the database. S...

Should the entity framework + self tracking entities be saving me time

I've been using the entity framework in combination with the self tracking entity code generation templates for my latest silverlight to WCF application. It's the first time I've used the entity framework in a real project and my hope was that I would save myself a lot of time and effort by being able to automatically update the whole da...

Self Tracking Entities with Pre-Generated Views

I am currently using the Self Tracking entities of the .NET Entity Framework, however I would like to speed up my execution of queries. The first thing everyone seems to suggest is generate the views for the model at compile time. Using the ssdl files etc, I was able to create a 'MyModel.Views.cs', which is compiled in my project. Howe...

Entity Framework 4.0 - Can I send a complex type to the client over WCF ?

Hey, can anybody confirm the following scenario will work: I am developing a 3-tier application in .NET 4.0: Winforms Client, aspx server and SQL 2008 database. The server communicates with the SQL 2008 database by means of Entity Framework 4.0, and returns the entities in forms of STE's (in a separate assembly) to the client applicati...

Self Tracking Entities versus timestamp column in database

In an optimistic concurrency scenario fo a web-app, I am considering to give each table the timestamp column (sqlserver), comparable to a guid. Linq to entities will then generate sql update queries like WHERE id = @p0 AND timestamp = @p1 when one decorates the timestamp column with a certain attribute in Entity Framework. When the numb...

Self-tracking entities extension methods

When the context is generated i see there are some extension methods : AcceptChanges, MarkAsAdded, MarkAsDeleted, MarkAsModified. When should i use these methods since they are available only on the service? ...

Self tracking entities return Unchanged in my WCF service

I've set up a little n-tier web application using MVP (Model View Presenter) in the front-end, a WCF service on the backend, which communicates with the BLL an behind that the DAL, which communicates with the EF4.0. This is all working quite nicely, I've created several Get and Add methods which all work. Now I wanted to create several ...

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

Hi, 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 Tracking Entity (STE) + WCF. Steps: Call data store for a list of assets. Call ...

EF4 STE's and MVC2 - ChangeTracker not POSTing

I'm trying to set up an MVC2 app with Entity Framework Self-Tracking-Entities. My view is a strongly-typed view of the entity type generated by the STE T4 template. Here's my GET: public ActionResult Edit(int id) { var ri = new App1Service.App1Client().GetMyObj(id); var changeTracking = ri.ChangeTracker.ChangeT...

How to create and store a (self-tracking) entity object on the server side?

Hi everyone, I am trying to achieve the following using Entity framework 4.0 and self-tracking entities: 1) The client application request a book form the server by providing an ISBN number 2) The server performs a query on its database to see if the book is already present 3a) If the book is in the database, it returns it. 3b) If t...

With entity framework's self tracking entities, can I perform an explicit load?

I wish to return a graph for a "Business" entity. The Buiness entity has a collection of "Contacts". So I basically want this: ctx.Business.Include("Contacts").Where(b => b.BusinessID == id).Single(); The problem is I don't want ALL the contacts for the business. Just those that have a ContactTypeID = x. How can I accomplish this? I ...

Self Tracking Entities - Deleting from Navigation Property does not set state to 'Deleted'

In the constructor of each of my POCO's I have this: this.StartTracking(); To ensure that tracking is turned on for every instance of one of my POCO's. I have an Entity A which contains a TrackableCollection of Entity B. When I load my instance of Entity A like such: using(MyContext ctx = new MyContext()) { entityA = ctx.EntityA....