CodeFirst int类型主键问题 column does not allow nulls. INSERT fails.
来源:互联网 发布:淘宝小视频保存到手机 编辑:程序博客网 时间:2024/06/15 20:10
关于EF主键问题
[Key] public int ID { get; set; }默认约定下带ID的做为主键,并且是自增长列,种子为1,
问题:
当默认情况下添加数据时如果ID=0则会抛出异常:
Cannot insert the value NULL into column 'ID', table 'WXData.dbo.UserGroup'; column does not allow nulls. INSERT fails.The statement has been terminated.如果主键不是自增长列,需要0数据的时候,可以显示指定主键的生成方式
[DatabaseGenerated(DatabaseGeneratedOption.None)] public int ID { get; set; }
就能解决了。
更多属性这是问题:http://blog.163.com/m13864039250_1/blog/static/21386524820152831234140/
0 0
- CodeFirst int类型主键问题 column does not allow nulls. INSERT fails.
- SQL Server column not allow Null,insert failed
- ERROR: column "..." does not exist
- column '_id' does not exist
- column '_id' does not exist
- React-Native Strict mode does not allow ...
- EHCache does not allow attribute "maxEntriesLocalHeap".
- Repository does not allow updating assets 解决方法
- Argument of type '(Foo::)(int,int)' does not match 'void (*)(int,int)'以及静态函数问题
- 关于System.Security.SecurityException: That assembly does not allow partially trusted callers.问题的解决!
- 解决No Hibernate Session bound to thread, and configuration does not allow create tansactional的问题
- composer遇到Your configuration does not allow connection to http://的问题怎么解决
- composer遇到Your configuration does not allow connection to http://的问题怎么解决
- Ehcache配置问题(二)Element <cache> does not allow attribute "maxEntriesLocalHeap".
- 解决No Hibernate Session bound to thread, and configuration does not allow create tansactional的问题
- Note: C++ does not support default-int 问题
- sqoop导数类型不支持解决方法:Hive does not support the SQL type for column
- ERROR: column "..." does not exist(postgre--hibernate)
- Android中的线程池(二)
- 回溯法
- 项目SVN分支项目和并操作
- Nginx配置文件详细说明
- 查看Oracle数据库DBA角色,以及如何去除用户的DBA权限
- CodeFirst int类型主键问题 column does not allow nulls. INSERT fails.
- iOS 读取图片的各种方法
- 最简单SSH工具:PUTTY/PSCP/PSFTP
- 为什么你应该(从现在开始就)写博客
- 欢迎使用CSDN-markdown编辑器
- javaEE配置全局日期转换器
- Zend Studio屏蔽错误
- 给用户增加SAP_ALL权限
- Android应用加入微信分享