Saving collection to EntityFrameworkCore

Hello, I have a model with a few List of type string attributes.

using System.ComponentModel.DataAnnotations; using System.Collections.Generic; namespace BackEnd.Models { public class Project { public int Id { get; set; } [Required] [StringLength(40, MinimumLength=3)] public string Title{ get; set; } public List<string> Bugs{ get; set; } public List<string> InProgress{ get; set; } public List<string> ToDo{ get; set; } public List<User> Members{ get; set; } } } 

When I go to make a migration I get this message:

The property 'Project.Bugs' could not be mapped, because it is of type 'List<string>' 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'. 

How do I go about adding a generic list to my database? I’m using MySQL with the Pomelo SQL database connector.

Thanks in advance!

Edit: Also how would I go about doing this to my custom “User” object as well?

submitted by /u/redbeat0222
[link] [comments]

Leave a Reply