Check my blog post about StoreGeneratedPattern
. It explains some differences between Identity
and Computed
. When using StoreGeneratedPattern
for ID (PK) the correct option is None
if you assign ID in the application or Identity
if you assign ID in DB. Computed
option is "invalid" because this option is used when value is changed during each entity persistence (also in updates) and it is not the case of ID.
The difference between Identity
and Computed
is behavior of executed SQL command. If property is Identity
EF will select the value after Insert and return it to your application. If property is Computed
EF will select the value after both Insert and Update and return it to your application.
Edit:
StoreGeneratedPattern.Identity
is not related to Identity in DB. You don't need to have Identity in DB and you can set ID with some different techinque (default value for guid or trigger) but you still need StoreGeneratedPattern.Identity
to get value back to your application.
Once you are using Identity
or Computed
EF will always follow each Insert or Update with Select for db generated columns. It can't work without it. These commands are executed in single roundtrip to database so there is almost none performance impact.