I cant add a controller, it says:
Unable to retrieve Metadata for "Diets.Models.Usuario" The Property "ProgramaDietaID" cannot be configurated as Navigation Property. The property must be a valid Entity and the property should have a non-abstract getter and setter. For collection Properties the type must implement ICollection where T is a valid entity type.
I don't figure out what I'm doing wrong, the roles between "Usuario" and "ProgramaDieta" entities are one-to-many.
public class Usuario
{
[Key]
[Required]
public int UsuarioID { get; set; }
[Display(Name = "Name:")]//lo que mostrara el titulo del campo la Vista.
[StringLength(50, ErrorMessage = "The name cannot be longer than 50 characters.")]
[RegularExpression(@"^[a-zA-Z''-'\s]*$")]//para que acepte solo letras y no carac. alfanumericos.
[Required]
public string Nombre { get; set; }
public virtual ICollection<ProgramaDieta> ProgramaDietas { get; set; }
}
public class ProgramaDieta
{
[Key]
public int ProgramaDietaID { get; set; }
[ForeignKey("UsuarioID")]
public int UsuarioID { get; set; }
public virtual Usuario Usuario { get; set; }
}
Context Class
public class MejoraConProgramasContext:DbContext
{
public MejoraConProgramasContext()
: base("MejoraConProgramasContext")
{
}
public DbSet<Usuario> Usuarios { get; set; }
public DbSet<ProgramaDieta> Programas { get; set; }
}