类型'System.InvalidOpera的例外 [英] An exception of type 'System.InvalidOpera

查看:110
本文介绍了类型'System.InvalidOpera的例外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

EntityFramework.dll中出现'System.InvalidOperationException'类型的异常但未在用户代码中处理



附加信息:关键字段'Id'不能的值为null。在邀请类型上定义的关键字段需要非空值。

An exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll but was not handled in user code

Additional information: The key field 'Id' cannot have a value of null. A non-null value is required for the key fields defined on type 'Invite'.

推荐答案

如果您要使用ef发布实体的代码,那将会很好属性。但是您可能在Id上添加了DatabaseGenerationOption.None,这意味着它不会自动创建为自动增量值。因此值为NULL,这是无效的(因为它最肯定也是实体的主键)



祝你好运!
Would be nice if you would post the code of your entity with the ef attributes. But you probably added the DatabaseGenerationOption.None on the Id, meaning it won't be created automatically as auto increment value. Therefor the value is NULL and this is invalid (as it most certain is also the primary key for the entity)

Good luck!


这篇关于类型'System.InvalidOpera的例外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆