Entity framework code-first null foreign key

前端 未结 4 1415
梦如初夏
梦如初夏 2020-11-28 05:34

I have a User < Country model. A user belongs to a country, but may not belong to any (null foreign key).

How do I set this up? When I t

4条回答
  •  一向
    一向 (楼主)
    2020-11-28 06:02

    I recommend to read Microsoft guide for use Relationships, Navigation Properties and Foreign Keys in EF Code First, like this picture.

    Guide link below:

    https://docs.microsoft.com/en-gb/ef/ef6/fundamentals/relationships?redirectedfrom=MSDN

提交回复
热议问题