Model validation error: EntityType has no key defined. Define the key for this EntityType

asp.net-mvc asp.net-mvc-5 c# entity-framework entity-framework-6

Popular Answer

by specifying

public virtual CultureInfo Culture { get; set; }

You are telling EF that the relevant table for public virtual properties is called CultureInfos: EF etiquette, and that property is a navigation property.

Continue to have CultureInfo on hand. Name should be specified as a string, followed by a getter property that will return the appropriate CultureInfo object.

public string CultureName {get; set; }
public CultureInfo Culture {
    get { return new CultureInfo(CultureName); }
}
1
1/21/2016 4:08:43 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow