Logging caught an error in our application which I have been unable to reproduce. It did, however, catch the message which was:
The 'MyProperty' property on 'MyTable' could not be set to a 'null' value. You must set this property to a non-null value of type 'System.Int32'.
Which is fine, except that the 'MyProperty' property is certainly nullable. It's set to nullable in the table.
[MyProperty] [int] NULL,
And in the EDMX file for Entity Framework, Nullable was set to (None) but the Entity itself shows the property as nullable:
public Nullable<int> MyProperty { get; set; }
Intellisense shows this as int?
when creating Entities of this class.
Why is the system complaining about setting this field to null?
即使Entity generate的属性具有Nullable<int>
,在EDMX中将其设置为Nullable = true
似乎也已解决了该问题。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.