I use MVC 5 razor and I'm new to this.
I want to only display the projects that the user created. In my table project there is a FK to User as User_id.
I've used the ApplicationUser
model that is auto rendered at the start from a new project in MVC.
In my project controller:
private UserManager<ApplicationUser> manager;
public ProjectController()
{
manager = new UserManager<ApplicationUser>(
new UserStore<ApplicationUser>(db));
}
// GET: /Project/
[Authorize]
public ActionResult Index()
{
var currentUser = manager.FindById(User.Identity.GetUserId());
var proj = from p in db.Projects
where p.User == currentUser
select p;
return View(db.Projects.ToList(proj));
}
The error.
Unable to create a constant value of type 'herexamen800.Models.ApplicationUser'. Only primitive types or enumeration types are supported in this context.