I found a solution. I had two lines to replace in my controller:
ViewData["ApplicationUserId"] = new SelectList(_context.Users, "Id", "Id");
ViewData["ApplicationUserId"] = new SelectList(_context.Users, "Id", "Id", article.ApplicationUserId);
So I created two methods in 'ArticlesRepository.cs':
public SelectList GetUser()
{
var idUser = new SelectList(_context.Users, "Id", "Id");
return idUser;
}
public SelectList GetUserWithArticle(Articles article)
{
var idUser = new SelectList(_context.Users, "Id", "Id", article.ApplicationUserId);
return idUser;
}
and, in 'IArticlesRepository.cs':
SelectList GetUser();
SelectList GetUserWithArticle(Articles article);
Which gives, in the new controller:
ViewData["ApplicationUserId"] = _repo.GetUser();
ViewData["ApplicationUserId"] = _repo.GetUserWithArticle(article);
It works. Thanks!