System.Data.Entity.ModelConfiguration.ModelValidationException: 'One or more validation errors were detected during model generation:
BackEnds.Producte: : EntityType 'Producte' has no key defined.
I get this error when I connect to the database, could you explain where I'm making a mistake?
CodePudding user response:
Without an example of your code and the definitions of your entities, nobody will be able to help. My educated guess (based on the error message) is that the Producte entity has no key defined.
Try to decorate the property of the entity that holds the key with the Key attribute, like this:
public class Producte
{
[Key]
public Guid Id {get; set;}
public string Name {get; set;
}
CodePudding user response:
Try by decorating the Identity Column property like for example "ProductID" of the entity "Producte" with an attribute "[key]".
Ex.
[key]
public int ProductID {get;set;}
refer this link