我对 AutoMapper 还很陌生。我很难将 AutoMapper 配置为能够将UserViewModel多个映射TagViewModel为多对多关系 ( RecipeEntity <-> TagEntity),这是 Entity Framework Core 所需UserAndTagEntity的连接表。
数据对象:
public class TagEntity
{
public string Name { get; set; }
public virtual ICollection<UserAndTagEntity> UserAndTags { get; set; } = new List<UserAndTagEntity>();
}
public class UserEntity
{
public string Name { get; set; }
public virtual ICollection<UserAndTagEntity> UserAndTags { get; set; } = new List<UserAndTagEntity>();
}
public class UserAndTagEntity
{
public int Id { get; set; }
public virtual …Run Code Online (Sandbox Code Playgroud)