Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Edited Unassigned: EntityType 'DbGeography' has no key defined. Define the key for this EntityType.-> Error occur if I use base class to define a key [1535]

$
0
0
I get an error for define DbGeography in EF6 (i don't have this Error in EF5) entity type if I use it from base class to define key: for this class :

public class University
{
public int UniversityID { get; set; }
public string Name { get; set; }
public DbGeography Location { get; set; }
}
university class mapping:

class UniversityMap : EntityTypeConfiguration<University>
{
public UniversityMap()
{
this.ToTable("University");
this.HasKey(u => u.UniversityID);

}
}
everything is correct and EntityFramework does it correctly, but if I change class to :

public class BaseClass
{
public int UniversityID { get; set; }
}
public class University:BaseClass
{
public string Name { get; set; }
public DbGeography Location { get; set; }
}
I get the following error:

One or more validation errors were detected during model generation:

Data.DbGeography: : EntityType 'DbGeography' has no key defined. Define the key for this EntityType. DbGeographies: EntityType: EntitySet 'DbGeographies' is based on type 'DbGeography' that has no keys defined.

!!!??? Thanks

Viewing all articles
Browse latest Browse all 10318

Trending Articles