Mam problem przy pobieraniu danych z bazy do DropDownListFor. Proszę o wskazówki co jest źle. Dostaje taki błąd:
The model item passed into the dictionary is of type 'System.Data.Entity.Infrastructure.DbQuery
1[SZ.Entities.Province]', but this dictionary requires a model item of type 'SZ.Models.RegisterModel'.`
AccountModels.cs:
public class RegisterModel
{
....
public string Name { get; set; }
public List<SelectListItem> ProvinceList { get; set; }
...
}
_RegisterSystem.cshtml:
@Html.DropDownListFor(m => m.Name, new SelectList(Model.ProvinceList, "Id", "Name"))
LoginSysController.cs:
public List<Province> ProvinceList = new List<Province>();
public ActionResult _RegisterSystem()
{
EFDbContext _context = new EFDbContext();
var resultProvinces = from c in _context.Provinces
where c.Name == null
select c;
return View(resultProvinces);
Entity Province.cs:
public class Province
{
public int Id { get; set; }
public string Name { get; set; }
}
EFDbContext.cs:
public class EFDbContext : DbContext
{
....
public DbSet<Province> Provinces { get; set; }
}