In my database I have a Vehicle table with a primary key. I am creating a new Vehicle object using
new Vehicle();
and updating the properties of vehicle appropriately. When I try to do a
genesisContext.Vehicles.AddObject(vehicle);
The first time the table is successfully updated and the primary key is 0. On all subsequent occassions I get an error saying that the key is not unique
{"Violation of PRIMARY KEY constraint 'VEHICLES_PK'. Cannot insert duplicate key in object 'dbo.Vehicles'.\r\nThe statement has been terminated."}
(presumably because the primary key set by the EF is still 0).
I was under the understanding that the EF intelligently works out primary keys so why is this happening??