Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/313.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 实体框架一对多关系、迁移_C#_Asp.net Mvc_Entity Framework - Fatal编程技术网

C# 实体框架一对多关系、迁移

C# 实体框架一对多关系、迁移,c#,asp.net-mvc,entity-framework,C#,Asp.net Mvc,Entity Framework,嗨,我有以下实体: public class EntityOne { public int EntityOneID { get; set; } public string Smth { get; set; } public string User1Id { get; set; } public string User2Id { get; set; } public virtual ApplicationUser User1 { get; set;

嗨,我有以下实体:

public class EntityOne
{

    public int EntityOneID  { get; set; }

    public string Smth { get; set; }

    public string User1Id { get; set; }
    public string User2Id { get; set; }

    public virtual ApplicationUser User1 { get; set; }
    public virtual ApplicationUser User2 { get; set; }


}

public class ApplicationUser : IdentityUser
{
    public virtual ICollection<EntityOne> EntityOnes { get; set; }
}
我想要两个与“EntityOne”有关系的不同用户

编辑:可能的答案:

public class ApplicationUser : IdentityUser
{
    public virtual ICollection<EntityOne> EntityOnes1 { get; set; }
    public virtual ICollection<EntityOne> EntityOnes2 { get; set; }
}
公共类应用程序用户:IdentityUser
{
公共虚拟ICollection EntityOnes1{get;set;}
公共虚拟ICollection EntityOnes2{get;set;}
}

当我在ApplicationUser中创建两个集合时,一切都正常。

不能将两个不同的关系与同一属性关联

导航属性提供了一种在两种实体类型之间的关联中导航的方法。对于每个对象所参与的每个关系,每个对象都可以有一个导航属性


尝试此更改将取消删除(true);
Schema specified is not valid. Errors: The relationship    'SomeProject.Models.EntityOne_User1' was not loaded because the type 'SomeProject.Models.ApplicationUser' is not available.
public class ApplicationUser : IdentityUser
{
    public virtual ICollection<EntityOne> EntityOnes1 { get; set; }
    public virtual ICollection<EntityOne> EntityOnes2 { get; set; }
}