我有一个实体,我试图将它添加到两个不同实体的集合中。
我想要达到的目标是
[1] => DomainUser { name = "bob" }
DomainGroup.Users = [ 1 ]
LocalGroup.Users = [ 1 ]
但是,当我尝试保存更改时,我得到Multiplicity constraint violated. The role 'DomainGroup_Users_Source' of the relationship 'Server.DomainTools.Models.DomainGroup_Users' has multiplicity 1 or 0..1.
这是我的实体:
这就是我觉得我的问题所在:DomainUser
public class DomainUser
{
public string Name { get; set; }
public int Id { get; set; }
public string DisplayName { get; set; }
public string DistinguishedName { get; set; }
public int AdminCount { get; set; }
public int PwdLastSet { get; set; }
public string AdsPath { get; set; }
public int LastLogon { get; set; }
public int LastLogoff { get; set; }
public int LockoutTime { get; set; }
public int AccountExpires { get; set; }
public int BadPwdCount { get; set; }
public int LogonCount { get; set; }
}
以下是我尝试将DomainUser添加到的两个实体:DomainGroup和LocalGroup
public class DomainGroup
{
public string Name { get; set; }
public List<DomainUser> Users { get; set; }
public List<DomainGroup> Groups { get; set; }
public string DistinguishedName { get; set; }
public int Id { get; set; }
public DomainGroup()
{
Users = new List<DomainUser>();
Groups = new List<DomainGroup>();
}
}
public class LocalGroup
{
public string Name { get; set; }
public int Id { get; set; }
public string DisplayName { get; set; }
public string Comment { get; set; }
public List<LocalUser> LocalUsers { get; set; }
public List<DomainUser> DomainUsers { get; set; }
public List<DomainGroup> DomainGroups { get; set; }
public List<LocalGroup> LocalGroups { get; set; }
public LocalGroup()
{
LocalUsers = new List<LocalUser>();
LocalGroups = new List<LocalGroup>();
DomainUsers = new List<DomainUser>();
DomainGroups = new List<DomainGroup>();
}
}