I want learn EF 6 CodeFirst to an Existing Database (SQLServer)
When I trying to run my project i got this error:
Exception
System.ArgumentNullException: Value cannot be null. Parameter name: source
Controller
public ActionResult Index()
{
var meetings = db.Meetings
.OrderBy(e => e.StartDate)
.Where(e => e.IsPublic)
.Select(e => new MeetingViewModel()
{
MeetingId = e.MeetingId,
MeetingName = e.MeetingName,
MeetingTypeName = e.MeetingType.Name,
LocationName = e.MeetingLocation.Name,
StartDate = e.StartDate,
});
var upcomingMeetings = meetings.Where(e => e.StartDate > DateTime.Now);
var passedMeetings = meetings.Where(e => e.StartDate <= DateTime.Now);
return View(HomeIndex, new HomePageModel());
}
Page Model
public class HomePageModel
{
public IEnumerable<MeetingViewModel> UpcommingMeetings { get; set; }
public IEnumerable<MeetingViewModel> PassedMeetings { get; set; }
}
Cshtml
@model AquaEvent.Common.HomePageModel
<div class="row">
@if (Model.UpcommingMeetings.Any())
{
@Html.DisplayFor(x => x.UpcommingMeetings)
}
</div>
connectioString is EF AutoGenerator without changing