开发者

Object Generated From Entity Model Does Not Create Nullable Foreign Keys

开发者 https://www.devze.com 2023-03-30 03:36 出处:网络
I have noticed some strange behavior when it comes to nullable foreign keys in my database. I have just started playing with the entity framework so I\'m probably doing something wrong, but I cannot f

I have noticed some strange behavior when it comes to nullable foreign keys in my database. I have just started playing with the entity framework so I'm probably doing something wrong, but I cannot figure this one out.

Say I have the following two 开发者_运维问答tables: (CountryID is a foreign key that is nullable)

Object Generated From Entity Model Does Not Create Nullable Foreign Keys

When I create a new entity model I end up with this:

Object Generated From Entity Model Does Not Create Nullable Foreign Keys

But the CountryID properties are set to Nullable (None) - instead of True. Obviously this is a really trivial example, but with a large database it would be difficult switch all of these manually. Is there any way to have the entity framework use a nullable int? for these foreign keys?

0

精彩评论

暂无评论...
验证码 换一张
取 消