1

I have a strange problem when using Entity Framework code first.

When I return an object with dbContext.Users.Where... I don't get the User defined in my model, but User_{GUID}.

Is there anyone who knows this phenomenon and can help?

Regards, Ajit

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
AjitChahal
  • 221
  • 2
  • 7
  • Read about [EF's concept of dynamic proxies](http://www.develop.com/entityframework4) - it does this to be able to track changes. [You can turn it off, if you want to](http://stackoverflow.com/questions/7111109/should-i-enable-or-disable-dynamic-proxies-with-entity-framework-4-1-and-mvc3) – marc_s Feb 10 '12 at 14:30

1 Answers1

1

If your dbContext.Users if of a type DbSet<User> then you would get a User-castable type instance if you query Users collection.

User_{GUID} looks like a dynamic proxy object to a User instance in your DbContext. Treat it as if it was a User instance.

Maxim V. Pavlov
  • 10,303
  • 17
  • 74
  • 174