Skip to content

EntityType has no key!

January 2, 2016

If you receive the following error whilst adding records into the Entity Framework, it is likely that the Id field has no Key tag added.

One or more validation errors were detected during model generation:

WebApplication.Customer: : EntityType ‘Customer’ has no key defined. Define the key for this EntityType.
Clients: EntityType: EntitySet ‘Customers’ is based on type ‘Customer’ that has no keys defined.

To correct this, just add [Key] in the right class field name and it should work!


From → Uncategorized

Leave a Comment

Leave a Reply

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

You are commenting using your 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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: