I'd want to store in User class collection of Items
But I cannot overcome this problem:
System.InvalidOperationException: 'The property 'User.ItemsIds' could not be mapped, because it is of type 'List' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.'
I'm using ASP.NET Core 2.0 + EFCore
public class User
{
[Key]
public Guid Id { get; set; }
[ForeignKey("Items")]
public virtual List<Guid> ItemsIds{ get; set; }
(...)
}
public class Item
{
[Key]
public Guid Id { get; set; }
public string ItemName { get; set; }
public Item(string name)
{
Id = new Guid();
ItemName = name;
}
}
public class AppContext : DbContext
{
public AppContext(DbContextOptions<AppContext> options) : base(options)
{
Database.SetCommandTimeout(35000);
}
public DbSet<User> Users { get; set; }
public DbSet<Item> Items { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<User>().ToTable("Users");
modelBuilder.Entity<Item>().ToTable("Items");
}
}
Here's similar problem, but still it hasn't been "fixed"?