EntityKeys are case sensitive

If you create an Entity Key on the fly:

dim ekey=New EntityKey("NWentities.Customer","customerID",1234)

then add it to an object

cust.EntityKey=ekey

and then try to Attach the object to a context

cust.EntityKey=ekey

and you get this error message

The member with identity 'NWentities does not exist in the metadata collection.
Parameter name: identity

It's telling you that you have NWentities improperly cased. In my model, it's really NWEntities.

If you get this error message,

The required entry ''customerID' was not found in the provided input. This entry is required by the key fields defined on type 'NWModel.Customer'

then the issue is that the  property name is cased incorrectly.

You can only guess how long it took me to figure that out. Hopefully this will help someone doing a google search in the future.

#1 Phil on 10.15.2008 at 12:06 PM

Most useful, Thanks!

#2 Jason on 9.15.2009 at 11:29 AM

Thanks, saved some hair pulling

#3 Branev on 12.06.2009 at 10:06 AM

Thanks...led me to some ideas :)

#4 yad on 4.12.2010 at 4:40 PM

thanks, i fat fingered something on a refactoring and ended up with the above error.

#5 Adam Tuliper on 10.08.2010 at 12:07 AM

Dont forget your key may also be plura.. Entity.Users (even though your class is named User) or in the case above NWentities.Customers

#6 Ben Hoffman on 10.18.2010 at 4:46 PM

I have also noticed that in some cases my Entity Set Name is plural but my Entity Name is singular for the same entity!! This is occuring in ASP.Net 3.5.