I am working on a project where i need to convert an old database so the data can be used in my new solution.
For the new solution i am using Entity framework.
I want to make sure that the id's of the objects remains the same as in the old database, so i want to create an object with a specific id. After the conversion, the id field must auto-increment (as usual)
I know i can use a sql statement like this:
SET IDENTITY_INSERT cao_dev.CAO.CAO_unicornSet ON
But i still cannot set the id of the created object...
I did not find anything on the web so i am quite desperate...
Here is a part of my code:
unicorn.Id = id 'from db unicorn.name = "Unicorn 1" db.unicornSet.AddObject(unicorn) db.SaveChanges()