多重性和EF 6的问题

这发生在没有的地方。 我之前从未遇到过这个问题。 我刚刚在我的SQL Azure数据库中添加了一个表,该数据库将为注册我们的电子邮件列表的人保留电子邮件。 没有关联到该表的关联,它只是单独的。 我回到VS并从我的数据库更新我的模型,现在得到这些错误。

Error 1 Error 113: Multiplicity conflicts with the referential constraint in Role 'Category' in relationship 'FK_Items_3'. Because all of the properties in the Dependent Role are non-nullable, multiplicity of the Principal Role must be '1'. C:\Users\chuyita\Documents\Visual Studio 2012\Projects\gcaMusicExchange\gcaMusicExchange\myConnection.edmx 1043 11 gcaMusicExchange 

 Error 2 Error 113: Multiplicity conflicts with the referential constraint in Role 'Manufacturer' in relationship 'FK_Items_4'. Because all of the properties in the Dependent Role are non-nullable, multiplicity of the Principal Role must be '1'. C:\Users\chuyita\Documents\Visual Studio 2012\Projects\gcaMusicExchange\gcaMusicExchange\myConnection.edmx 1055 11 gcaMusicExchange 

我知道这是关于关系的一个问题,但我没有改变任何事情,也不明白为什么现在抱怨。

我检查了这个http://msdn.microsoft.com/en-us/data/jj591620.aspx并最终将设计器中的2个关系从0..1 (Zero or One of Manufacturer)更改为1 (One of Manufacturer)最终解决了第一个错误。 我对第二个错误做了同样的事情,现在问题都消失了。 我不完全确定这里发生了什么,我担心这样继续我的项目可能会导致更多的问题。

任何人都可以提供有关可能出错的任何见解吗?

 public partial class Category { public Category() { this.Items = new HashSet(); } public int id { get; set; } public string Name { get; set; } public virtual ICollection Items { get; set; } } public partial class Manufacturer { public Manufacturer() { this.Items = new HashSet(); } public int id { get; set; } public string Name { get; set; } public virtual ICollection Items { get; set; } } public partial class Item { public Item() { this.PrivateMessages = new HashSet(); } public int id { get; set; } public int SellingUserId { get; set; } public string Title { get; set; } public string Body { get; set; } public Nullable Price { get; set; } public Nullable IsActive { get; set; } public Nullable PostDate { get; set; } public Nullable LastGarbageCollectionDate { get; set; } public Nullable SoldToUserId { get; set; } public string Uri1 { get; set; } public string Uri2 { get; set; } public Nullable ZipCode { get; set; } public int CategoryId { get; set; } public int ManufacturerId { get; set; } public Nullable WaitingForSoldConfirmation { get; set; } public Nullable PendingSoldTo { get; set; } public Nullable Views { get; set; } public Nullable AcceptsTrades { get; set; } public Nullable MakeId { get; set; } public Nullable ModelId { get; set; } public Nullable YearId { get; set; } public Nullable Type { get; set; } public string Uri3 { get; set; } public string Uri4 { get; set; } public string Uri5 { get; set; } public virtual Category Category { get; set; } public virtual Manufacturer Manufacturer { get; set; } public virtual VehicleMake VehicleMake { get; set; } public virtual VehicleModel VehicleModel { get; set; } public virtual VehicleYear VehicleYear { get; set; } public virtual ICollection PrivateMessages { get; set; } } 

如果您想拥有不可为空的密钥,则需要1->多个关系。 将有问题的关系更改为0 – >很多。

我假设关系约束在某些时候被改变了,这是一个数据第一个项目吗? 如果是,您确定在数据库级别没有更改约束吗?