EntityType has no key defined. Define the key for this EntityType

While running “Add-Migration” I kept receiving the following error in a new ASP.NET C# project using Entity Framework.

 

Ebs.Job.Models.JobListing: : EntityType ‘JobListing’ has no key defined. Define the key for this EntityType. JobListings: EntityType: EntitySet ‘JobListings’ is based on type ‘JobListing’ that has no keys defined.

The code in question was the following:

public class JobListing
{
     [Key]
     public UInt32 Id { get; set; }

The answer is that as of 6/12/2014, Entity Framework does not support unsigned integers.  Once I changed the UInt32 to Int32, everything worked great.

Advertisements

One thought on “EntityType has no key defined. Define the key for this EntityType

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s