Entity Framework: Identity Errors

If you create a table with a PK that is not identity and then create a EF class from that and then try and load in an empty value, you get a System.Data.Update exception:

image

 

If you go ahead and change the server to identity without updating EF on your client, you still get a System.Data.Update exception, but with a different inner exception:

image

What you need to do is to fix it by changing to identity and then updating the EF on the client:

image

Volia: the change will now persist

However, if you create a PK on an existing table where there used to be a Implied key, you get an error. You need to drop the table and re-create.

Advertisements

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 )

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: