本文介绍了无效的外键;实体框架5.0模型第一的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是使用Visual Studio 2012 Express的Entity Framework 5.0第一种方法。我有一个方案来生成一个可空的外键。例如,有两个实体 - 组织用户。并非所有用户都属于组织。但是,一些用户将属于一个组织。尽管改变了多重性,但是 User.Organization_ID 列总是 not null 请帮我解决这个问题。欣赏它。

I'm using Entity Framework 5.0 model-first approach using Visual Studio 2012 Express. I have a scenario to generate a nullable foreign key. For example, there are two entities – Organization and User. Not all users will belong to an organization. However, some users would belong to an organization. The User.Organization_ID column is always not null in spite of changing the multiplicity. Please help me to resolve this issue. Appreciate it.

推荐答案

更改多重性0..1 - > *(很多)修复了此问题。即0或1个组织可以具有0个或更多个用户。这样,用户表中的organizatio_id就被生成为可空的列!感谢大家帮忙!

Changing the multiplicity 0..1 --> * (many) fixed this issue. i.e. 0 or 1 organization can have 0 or more users. This way, the organizatio_id in the user table is generated as nullable column! Thanks everyone for helping!

这篇关于无效的外键;实体框架5.0模型第一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 15:14