C# 保存列表<;int>;
我有这样一件事:C# 保存列表<;int>;,c#,entity-framework,C#,Entity Framework,我有这样一件事: public class User { public int Id {get;set;} public List<int> Permissions {get;set;} } 公共类用户 { 公共int Id{get;set;} 公共列表权限{get;set;} } 作为一对多关系,我应该为这项工作做些什么?创建一个权限类型: public class User { public int Id { get; set; } p
public class User
{
public int Id {get;set;}
public List<int> Permissions {get;set;}
}
公共类用户
{
公共int Id{get;set;}
公共列表权限{get;set;}
}
作为一对多关系,我应该为这项工作做些什么?创建一个
权限
类型:
public class User
{
public int Id { get; set; }
public ICollection<Permission> Permissions { get; set; }
}
public class Permission
{
public int Id { get; set; }
public int Value { get; set; }
}
公共类用户
{
公共int Id{get;set;}
公共ICollection权限{get;set;}
}
公共类许可
{
公共int Id{get;set;}
公共int值{get;set;}
}
我尝试了一些直接插入的代码(Permissons.AddRange(listOfInt)),但后来我意识到没有为权限创建表。