开发者

Empty ObjectSets in TryGetObjectByKey

开发者 https://www.devze.com 2022-12-28 09:39 出处:网络
When I use TryGetObjectByKey on my ObjectContext, it returns an error. An item with a duplicate value already exists.

When I use TryGetObjectByKey on my ObjectContext, it returns an error. An item with a duplicate value already exists.

When I look at my ob开发者_运维技巧jectContext, I see that the ObjectSets are empty. What am I doing wrong? When I enumerate the ObjectSet by hand, by using ToArray on it, or by using the debugger, it does work.

LazyLoadingEnabled is set to true.

I reuse 2 tables from another EDMX, but they are in different namespaces and they are not the objectSets I try to approach.


it's not a duplicate. Its different.Sort of...

I finally found the solution. The Entity framework doesnt load the metadata correctly for POCO.

what you have to do on your OnContextCreated is this:

databaseContext.MetadataWorkspace.LoadFromAssembly(typeof(Entity).Assembly);

This will correctly load the metadata and it works.... I need to read into it... but this seems to do the trick.

http://social.msdn.microsoft.com/Forums/en/adodotnetdataservices/thread/601491ab-9c46-4fdf-88a7-c7392e5dbcdf

0

精彩评论

暂无评论...
验证码 换一张
取 消