简体   繁体   中英

Entity Framework Non-nullable column is mapped to a nullable entity property

I am getting this nullable column error message in Entity Framework 4.1 - when the column is not actually nullable:

Non-nullable column MyView.RunningTotal in table TransactionListView 
is mapped to a nullable entity property.

But you can see from the screenshots below that the column is not nullable and that the entity property is not nullable either. So why is this error occurring?

在此处输入图像描述

The straight-forward solution is to manually specify Nullable parameter to True.

2017 Update (Visual Studio 2017)

If the accepted straight-forward solution mentioned by lLya didn't help you, then this might. You may notice that when you save a diagram it does some work, like changing the class properties according to your diagram changes. One would think that the generator itself would be aware of these changes, right?. You might still get this error.

What fixed it for me was regenerating the database (right click in diagram -> Regenerate Database from Model).

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.

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