I have two models:
ApplicationUsers: ( The default that comes with Identity framework )
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
return userIdentity;
}
}
and Room:
public class Room
{
public int Id { get; set; }
public string RoomName { get; set; }
public ApplicationUser User1 { get; set; }
public ApplicationUser User2 { get; set; }
public ApplicationUser User3 { get; set; }
}
I created a new user at AppliactionUser:
And I manually added a new Room and reference to that User:
NOTE: It might not seem from the images, but their ids are the same, I doubled-checked it, the reason it looks different in these pictures is because there's not enough space to display the full length.
But when I ran my web and wrote this code on Home Controller :
public class HomeController : Controller
{
private ApplicationDbContext db = new ApplicationDbContext();
public ActionResult Index()
{
var varForDebug = db.Rooms.Find(1); // Room id 1
return View();
}
and made a breaking point at varForDebug I couldn't see an ApplicationUser at User1:
Why is that and how it could be solved?
Note: I'm using: ASP.NET MVC Web Application (.NET Framework ) 4.6.1 with Identity.
Note2: Include wants only string parameter from some reason, whys that?
Maybe I should consider adding Room property to ApplicationUser?