Tengo un código en C# Entity Framework code First.
Por un lado tengo Article
y por otro Tax
. Un un Articulo puede tener muchos Tax y un Tax puede estar en muchos Artículos. Muestro lo que estoy haciendo y el error que me da:
public class Tax
{
public int Id { get; set; }
[Display(Name = "Nombre")]
[MaxLength(50, ErrorMessage = "The {0} field can not have more than {1} characters.")]
[Required(ErrorMessage = "The field {0} is mandatory.")]
public string Name { get; set; }
public decimal Value { get; set; }
public ICollection<Article> Articles { get; set; }
}
public class Article
{
public int Id { get; set; }
[Display(Name = "Nombre")]
[MaxLength(200, ErrorMessage = "The {0} field can not have more than {1} characters.")]
[Required(ErrorMessage = "The field {0} is mandatory.")]
public string Name { get; set; }
public ArticleType ArticleType { get; set; }
public ArticleSubType ArticleSubType { get; set; }
public ICollection<Tax> Taxes { get; set; }
}
Al hacer la migración me da el siguiente error:
Unable to determine the relationship represented by navigation property 'Article.Taxes' of type 'ICollection'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.
Me pueden ayudar por favor Muchas gracias