Based on this tutorial i am trying to make my own project, but i have a problem
Visual Studio 2010 .net 4.0
SQL 2008 R2
My Database Table
Iller
ID int
ILKod varchar(5)
IlAciklama nchar(20)
My Model
namespace BilgiBankasi.Models
{
public class Iller
{
public int ID { get; set; }
public int ILKod { get; set; }
public string IlAciklama { get; set; }
}
public class BilgiBankasiEntities : DbContext
{
public DbSet<Iller> Iller { get; set; }
}
}
My Controller
namespace BilgiBankasi.Controllers
{
public class IlTestController : Controller
{
//
// GET: /IlTest/
BilgiBankasiEntities _db = new BilgiBankasiEntities();
public ActionResult Index()
{
var model = _db.Iller.ToList();
return View(model);
}
public ActionResult Create()
{
return View();
}
}
}
My View
@model IEnumerable<BilgiBankasi.Models.Iller>
In this situation i get this error
The model item passed into the dictionary is of type 'System.Collections.Generic.List
1[BilgiBankasi.Iller]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[BilgiBankasi.Models.Iller]'.
But when i use
This comes from Model.edmx
@model IEnumerable<BilgiBankasi.Iller>
works great.
What am i missing ? Am i doing something wrong or is there a bug? The Scaffolding from model doesn't work either. I create all views myself.
var model = _db.Iller.ToList().AsEnumerable();1[BilgiBankasi.Iller]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable1[BilgiBankasi.Models.Iller]'.DbContextAPI, but it seems you have a.edmx(ObjectContextAPI) file too, can you please more explain? Clean and ReBuild the entire solution, ma be helpful too.BilgiBankasi.Illerhanging around somewhere.