I'm building POCO classes for code-first EF to use in my ASP.NET MVC project. I'm trying to make a dropdown list for one of the fields based on this answer, but EF was threw an error when trying to add the migration.
Update: Removed SelectListItems from the POCO, but still same EF error.
Relevant snippet of the POCO:
using System.Web.Mvc;
public class Organization
{
[DisplayName("Bank Name")]
[Required(ErrorMessage = "Bank Name is required.")]
public string AccountBank { get; set; }
public IEnumerable<SelectListItem> Banks { get; set; }
}
EF Error:
Could not load file or assembly 'System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
This error occurs when the assembly for System.web.mvc that you included in your project does not match the version number you have explicitly defined in your config file. Go make sure the versions match.
Also, are you just trying to get the bank name via a drop down list in the view? If you are then you are adding unneeded complexity to your model by making the select list part of your model. You would be better off just loading that list into the viewbag and setting the selected value of it and o your model property.