views:

24

answers:

1

Hi,

is it possible to get entity key from EntityReference property without loading it?

I tried:

entity.EntityKey.EntityKeyValues[0].Value

But if referenced entity isn't loaded by EntityReference.Load() method, EntityKey property is null.

Thank's a lot!

A: 

In EF 4, use FK associations instead of independent associations if you want this feature.

For EF 1, EntityKey will be null if the query.MergeOption is MergeOption.NoTracking.

Craig Stuntz
Thanks, MergeOption was set to NoTracking.
Jan Remunda