There are two strategies:
Use Database-generated ID
(int
or GUID
)
Cons:
You should perform SaveChanges()
to get the ID
for just saved entities.
Pros:
Can use int
identity.
Use client generated ID
- GUID only.
Pros:
Minification of SaveChanges
operations.
Able to insert a big graph of new objects per one operation.
Cons:
Allowed only for GUID