I have a table with tasks and a table with tags between them a many-to-many relationship.
public class DbTask { [Key] public int TaskId { get; set; } public string Name { get; set; } public virtual ICollection<DbTag> Tags { get; set; } } public class DbTag { [Key] public int TagId { get; set; } public String Name { get; set; } public virtual ICollection<DbTask> Tasks{get; set;} } I create an object of the DbTask class on the client and add a list of DbTag objects already existing in the database. After that I send the created object to the server, where I add it to the database. When adding via the Add method to the table, not only a record about a new DbTask, but also a new DbTag is entered. How can I make a new entry contact the already existing DbTag?