I have the following model
public class PageConfig : Base
{
// Properties Etc..
public ICollection<Image> ScrollerImages { get; set; }
}
My approach is to bind using a junction table { PageConfigID, ImageID }.
In my model binder i tried the following..
modelBuilder.Entity<PageConfig>()
.HasMany(x => x.ScrollerImages)
.WithMany()
.Map(x =>
{
x.ToTable("junc_PageConfigScrollerImages");
x.MapLeftKey("PageConfigID");
x.MapRightKey("ImageID");
});
Which results in a null collection of images.
How can i bind these Images to the PageConfig model?
EDIT
Most of the problem was due to user error. jic this happens to you..
Check that the key constraints in the database are correctly set.
The ICollection on the model NEEDS to be virtual.