I am new to ASP.NET MVC, I am trying to learn, but I have the following error:
"Unable to retrieve metadata for 'AEMOS.Models.Proyects'. One or more validation errors were detected during model generation:
Proyects: : EntityType 'Proyects' has no key defined. Define the key for this EntityType.
Proyects: EntityType: EntitySet 'Proyects' is based on type 'Proyects' that has no keys defined.
I have searched Google for this error, even here in StackOverflow but cant reach a success.
This is my class:
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
namespace AEMOS.Models
{
public class Proyects
{
[Key]
public int ProyectsId { get;set;}
public string Name { get; set; }
public int Year { get; set; }
public Boolean Active = false;
}
}
I selected MVC 5 Controller with views, using Entity Framework for the controller creation. On the next window I selected the Model Proyects, Data Context ApplicationDbContext and the selected layout.
I have tried multiple class configurations (without [Key], with Key name Id instead of ProyectsId, ...).
Do you know whats happening?