简体   繁体   English

EF Core:ValueGeneratedNever()与完全不使用此方法

[英]EF Core: ValueGeneratedNever() vs. not using this method at all

What is the point of explicitly telling entity framework not to generate a value for a field in a database? 明确告诉实体框架不为数据库中的字段生成值有什么意义? There are two other options which are ValueGeneratedOnAdd or ValueGeneratedOnAddOrUpdate that make sense but does the framework by default generate a value so I have to disable it manually through that method? 还有另外两个选项是ValueGeneratedOnAddValueGeneratedOnAddOrUpdate ,它们是有意义的但是框架默认生成一个值,所以我必须通过该方法手动禁用它? If it does not, what is the ValueGeneratedNever() exactly for and what is the advantage of it? 如果没有,那么ValueGeneratedNever()究竟是什么,它的优点是什么?

For example, when you want to have manually assigned primary keys, you need to call this method. 例如,如果要手动分配主键,则需要调用此方法。 By convention, EF will assume that primary key properties are automatically generated. 按照惯例,EF将假定自动生成主键属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM