Im using the default Web Application with MVC + Identity for managing users, and im trying to make every registered user to make his movie list and to be able to see only his list when logs in.
So, for my example i have made a movie class
public class Movie
{
public int MovieId { get; set; }
public string MovieName { get; set; }
public string Year { get; set; }
public string Genre { get; set; }
public virtual ApplicationUser ApplicationUser { get; set; }
}
and in ApplicationUser i have put
public virtual ICollection<Movie> Movies { get; set; }
to have a list of movies.
I also made a Entity FrameWork MovieController, used Movie as model and ApplicationDbContext as context.
So i have problems querying the db in order to get each user to view only his movie list, with the default scaffolding i get this in index action of MoviesController
public ActionResult Index()
{
var movies = db.Movies.ToList();
return View(movies);
}
If anyone has experience with my problem please help, any input is welcomed and much appreciated.