Again I have problem with my project. I have two models created with EF 5 DBContext Generator:
First:
public int ID_AN { get; set; }
public string TITLE_OR { get; set; }
public string TITLE_EN { get; set; }
public virtual ICollection<GENRES> GENRES { get; set; }
Second:
public int ID_GE { get; set; }
public string GENRE { get; set; }
public virtual ICollection<ANIME> ANIME { get; set; }
After that I created controller:
public ActionResult Details(int id)
{
using (var db = new MainDatabaseEntities())
{
return View(db.ANIME.Find(id););
}
}
And View:
@model AnimeWeb.Models.ANIME
@{
ViewBag.Title = "Details";
}
<h2>Details</h2>
<fieldset>
<legend>ANIME</legend>
<div class="display-label">
@Html.DisplayNameFor(model => model.TITLE_OR)
</div>
<div class="display-field">
@Html.DisplayFor(model => model.TITLE_OR)
</div>
<div class="display-label">
@Html.DisplayNameFor(model => model.TITLE_EN)
</div>
<div class="display-field">
@Html.DisplayFor(model => model.TITLE_EN)
</div>
</fieldset>
To this point everything works fine, but I would like to display all Genres of selected anime. When I try to add
<div>
@Html.DisplayFor(model => model.GENRES)
</div>
I get an error: "The ObjectContext instance has been disposed and can no longer be used for operations that require a connection."
I'm new to MVC so I would be very gratefull if someone could explain to me how to make it possible to work.