What does StoreGeneratedPattern mean?

情到浓时终转凉″ 提交于 2019-12-08 14:45:46

问题


I'm doing EF design, who could tell me what does StoreGeneratedPattern mean?

I can't find a easy straight answer online.


回答1:


If you look at the samed called enumeration it tells what should be done if you insert or update rows:

  • None: No auto generated value is generated
  • Identity: A new value is generated on insert, but not changed on update
  • Computed: A new value is generated on insert and update



回答2:


These answers are also not an easy straight answer and just point to or repeat the same arcane documentation that the OP is referring to.

This attribute is used when the column is computed by the database. So on inserts and updates, the value will not be written.

The value will be read back from the database after inserts and updates, though I would guess that if set to Identity, EF may not read the value after an update since it won't have changed. Whether it really makes that tiny optimisation I don't know.

An example might be an identity column or a last updated time-stamp.



来源:https://stackoverflow.com/questions/4532477/what-does-storegeneratedpattern-mean

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!