Quantcast
Channel: Security
Viewing all articles
Browse latest Browse all 4737

Why was the "Users" implemented as an IDbSet and not an actual "DbSet" - whats the point of expanding it if I can't use .Include() for related entities?

$
0
0

Okay,

So, I have added new properties to the "ApplicationUser" object which derives from "IdentityUser". Some of these actual properties happen to be full blown entities that are stored in other System.Data.Entity.DbSets that I have added to the ApplicationDbContext. So the name of the users DbSet in my "ApplicationDbContext" is called "Users". Which is not an actual System.Data.Entity.DbSet but only an IDbSet which means it is not a System.Data.Entity.DbQuery, which means I can't use the .Include() method to include related entities from other System.Data.Entity.DbSet types that I might want to add in the ApplicationDbContext.

How do I query for related entities that I might want to attach from my custom System.Data.Entity.DbSet types on Microsoft's "forward thinking" Users IDbSet type?

**EDIT**: Problem solved. Alright peep's this was confusing for a few minutes but I found out all I have to do is cast the System.Data.Entity.IDbSet<TEntity> to a System.Data.Entity.DbSet<TEntity> and were back in business. Thanks for reading. You can all go back to sleep now.


Viewing all articles
Browse latest Browse all 4737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>