Object mapping could not be found for Type with identity {X}

02 May

If you try executing TryGetObjectByKey and you get the error above, you have missed to set the MetadataWorkspace in your ObjectContext.
This is achieved by doing the following:

Assembly a = typeof(MyContext).Assembly;
//ctx is the ObjectContext

After that you will be able to execute TryGetObjectByKey or other methods without getting exceptions.

Leave a comment

Posted by on May 2, 2012 in C-Sharp, EF



Leave a Reply

Please log in using one of these methods to post your comment: Logo

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

%d bloggers like this: