المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Adding Entity Framework 4.1 object to central database / key collisions



C# Programming
11-25-2011, 09:12 PM
I am uploading entities from one database to an identical one via a web service. The problem is that there are multiple copies of the database on multiple clients and this causes key collisions since we are using identity fields. For example, two identical tables will both have a key of "1". I am stuck with this schema, I'm afraid, so creating composite keys that would include an uploadclient key is not an option.

The central db is the same as the client databases, and is just intended to store all of the data from the upload clients.

I am writing LOTS of code that basically takes in an uploaded entity and creates a new one, then copies all of the properties into a new object before saving that new one to the database. This appears to be the only way to insert them with new keys since I can't use the key value of the uploaded object.

Given the constraints, does this sound like the best option? It's working fine, it is just a lot of code to type and I thought I would get some different views before I commit too much time to this.