c# - What is the recommended identity generation approach in Entity framework? -


I am interested in what is the best way for StoreGeneratedPattern.

In the past I used it DB to generate the ID for me but I was thinking that there is a benefit in setting

  StoreGeneratedPattern = None   

Instead of

  StoreGeneratedPattern = Identity   

I'm not even sure that when I set it in Calculation.

Any recommendations? Is there any good article related to this because MSDN is not very explanatory. I am mostly using inputs with some GUIDs in my schema.

About me StoreGeneratedPattern . It shows some difference between identity and calculation / correct choice when using StoreGeneratedPattern for ID (PK) any if you specify ID in the application or identity if you specify ID in the DB object is "invalid" option because this option is used when the value Every entity's persistence (as well as in the update) is changed and this ID Mal is not

identify and computed SQL command behavior. If the property is identity EF will insert the value after inserting it and return it to your application. If the property is computed to insert EF and update and return it to your application, then select the value.

EDIT:

StoreGeneratedPattern.Identity is not related to identity in DB. You do not need to identify in DB and you have some different techniques Set the default value for the grid or trigger), but still you need StoreGeneratedPattern.Identity to get the value on your application. / P>

Once you are using identification or computed EF, always enter or update each with the selection for the DB generated column Will follow. It can not work without these commands are executed in the database in a roundtrip, so there is almost no effect.

Comments