How to perform CRUD operations for a Model with a list of complex types with Entity Framework Code First?
<p>I'm attempting to perform CRUD operations on an entity that contains a list of a complex type. I've tried several approaches and performed various Google searches, but so far all I've found is problems.</p>

<p>I have the following ViewModels:</p>

<pre class="lang-cs prettyprint-override"><code>public class GameViewModel
{
    public long Id { get; set; }
    public string Name { get; set; }
    public string OfficialWebsiteUrl { get; set; }

    public ReleaseDateViewModel ReleaseDate { get; set; }
    public List&lt;ReleaseDateViewModel&gt; ReleaseDates { get; set; }
}
</code></pre>



<pre><code>public class ReleaseDateViewModel
{
    public long Id { get; set; }
    public long PlatformId { get; set; }
    public string PlatformName { get; set; }
    public long GameId { get; set; }

    public IEnumerable&lt;SelectListItem&gt; Platforms { get; set; }

    public bool IsActive { get; set; } = true;
}
</code></pre>

<p>I also have the following Platform model:</p>

<pre class="lang-cs prettyprint-override"><code>public class Platform
{
    public virtual long Id { get; set; }
    public virtual string Name { get; set; }
}
</code></pre>

<p>I've followed the advice on this extremely helpful post: <a href="https://stackoverflow.com/questions/21012297/generate-create-view-for-model-which-have-list-object-property">Generate create view for model which have List object property</a></p>

<p>I currently have the ability set up to Add a new Game, which also adds a list of new ReleaseDates to my database and I can view these. But I'm having trouble performing updates and deletions.</p>

<p>I need to be able to delete a single ReleaseDate, and delete and Update a Game. If a Game is deleted all relevant ReleaseDates should be deleted. - I have no idea how to implement this.</p>

<p>For brevity I've omitted some properties of the models above and I've not included any controller or view code. If you need any of that information to help answer the question or to help make this a more helpful post, then let me know and I'll add them in.</p>