整数?类型化属性使用 EF Code First 生成一个 0 填充列
在应用程序进入生产阶段之前,我一直使用实体框架代码优先方法来生成数据库。
现在我已将以下属性添加到我的实体对象之一。
public virtual int? ClaimIncidentId { get; set; }
然后我运行 SQL 迁移来自动更新数据库,使其符合当前的实体声明。
这导致在相应的表中生成一列。列名称为 ClaimIncidentId
,但为每个现有行填充的默认值是 0
,而不是 null
。
我如何显式地让 SQL 迁移生成 null
值列。除了实际值之外,列被声明为可为空,因此理论上,它应该在其中放入 null
。
I have a been using Entity Framework code first approach to generate a DB before the application went into a production phase.
Now I have added to following property to one of my entity objects.
public virtual int? ClaimIncidentId { get; set; }
Then I ran the SQL Migrations to automatically update the database so it would conform with the current entity declarations.
This has resulted in generation of a Column in the corresponding table. The column name is ClaimIncidentId
, but the default value, that got populated for each existing row was 0
, not null
.
How could I have explicitly let the SQL Migrations to generate a null
valued column. Other then an actual value, column is decleared as nullable, so theoretically, it should have put null
s in it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论