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

How do i query db.Users with navigation properties?

$
0
0

Hello,

In ASP.NET Identity 2.0, I am trying to extend the build-in Users Class to link to my person table.  There is a similar thread here, but he does not share his solution.

Here is how i extended the aspnetuser table:

namespace CAVU.DAL
{
    public class ApplicationUser : IdentityUser
    {
        public virtual Person Person { get; set; }
    }
    ........
}

In my controller, I want to do something like this:

var db = new myContext();
var users = db.Users.Include(p => p.Person);

Here is my Error:

'System.Data.Entity.IDbSet<####.DAL.ApplicationUser>' does not contain a definition for 'Include' and no extension method 'Include' accepting a first argument of type 'System.Data.Entity.IDbSet<####.DAL.ApplicationUser>' could be found (are you missing a using directive or an assembly reference?)

I have no trouble inserting data, but when it comes to selecting my data back out, it appears that I don't have the correct interface to join my person table using the navigation property defined above.

I don't want to add all of the fields directly into the ASPNetUsers table, rather I just want to link to another table: "Person".

Any Ideas?


Viewing all articles
Browse latest Browse all 4737

Trending Articles



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