CodeFirst EF4.1 MVC Against legacy database – Multiplicity conflicts

Hope this is still on time to help you. I was also having the exact same problem and was troubling with it for almost an hour until I could spot my mistake.

The problem is that Course.Venue relationship is optional (as declared on the fluent API), but the Id declaration of Course.VenueId is mandatory, so you can either make VenueId optional by changing it to

public int? VenueId { get; set;}

or change the relationship to mandatory on the fluent API, and the OnModelCreating should run fine once you changed that.

Leave a Comment

404 Not Found

Not Found

The requested URL was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.