views:

5

answers:

0

Hi -

I'm serializing an entity from an EF 4 context which has a GUID primary key. Works fine, everything is serialized into an XML file which is transmitted to another computer. There I need to get the object exactly as it is into the database on this host. And this is where things don't work anymore.

  • When I deserialize the entity and call AddObject in my target context, the entity is properly added to the target database on SaveChanges(), however, the entity gets a new primary key (i.e. a different GUID)

  • When I attach the entity, the object is added to the context, however, with an EntityState of "Unmodified". Changing the EntityState to "Added" results in the same problem as before.

Anybody's got an idea how to get this single, simple entity from database to database with exactly the same GUID?

Thanks, Phil