You can also do it by alternate way,follow this one
public class Country
{ [Required]
public int CountryId { get; set; }
public string CountryName {get;set:}
}
Controller
public ActionResult CountriesDropDown()
{
using(ctx)
{
var dropdown = (from q in ctx.Countries
select new Models.Country
{
Id = q.Id,
Name = q,CountryName
}
Viewbag.Country = dropdown;
return view();
}
Countries View
@model Models.Country
@Html.DropDownListFor(model => model.CountryId,new SelectListItem{@Viewbag.Country,CountryName,CountryId}, "please select");