I have a following query:
using (var forumsDb = new ForumsDb())
{
forumsDb.Configuration.LazyLoadingEnabled = false;
var categoryList = forumsDb.Categories.Select(c => c).ToList();
/***some code here***/
}
Now, categoryList contains 4 items (i have 4 categories in database), but all of them are of type dynamicproxies, and not (as i would expect) Category.
What am i doing wrong?
You aren’t doing anything wrong. EF wraps your entities in a version tracking proxy so that it can detect changes to your objects as well as support Lazy Loading.
If you want to remove the proxies, you can detach the object from the context, or you can turn off version tracking altogether by specifying
DbContext.Configuration.ProxyCreationEnabledfalse