Entity Framework circular dependency for last entity
<p>Please consider the following entities</p>

<pre><code>public class What {
    public int Id { get; set; }
    public string Name { get; set; }
    public ICollection&lt;Track&gt; Tracks { get; set; }
    public int? LastTrackId { get; set; }]
    public Track LastTrack { get; set; }
}

public class Track {
    public Track(string what, DateTime dt, TrackThatGeoposition pos) {
        What = new What { Name = what, LastTrack = this };
    }

    public int Id { get; set; }

    public int WhatId { get; set; }
    public What What { get; set; }
}
</code></pre>

<p>I use the following to configure the entities:</p>

<pre><code>builder.HasKey(x =&gt; x.Id);
builder.HasMany(x =&gt; x.Tracks).
    WithOne(y =&gt; y.What).HasForeignKey(y =&gt; y.WhatId);
builder.Property(x =&gt; x.Name).HasMaxLength(100);
builder.HasOne(x =&gt; x.LastTrack).
    WithMany().HasForeignKey(x =&gt; x.LastTrackId);
</code></pre>

<p>Has you can see there is a wanted circular reference:</p>

<pre><code>What.LastTrack &lt;-&gt; Track.What
</code></pre>

<p>when I try to add a <code>Track</code> to the context (on <code>SaveChanges</code> in fact):</p>

<pre><code>Track t = new Track("truc", Datetime.Now, pos);
ctx.Tracks.Add(t);
ctx.SaveChanges();
</code></pre>

<p>I get the following error:</p>

<blockquote>
  <p>Unable to save changes because a circular dependency was detected in the data to be saved: ''What' {'LastTrackId'} -> 'Track' {'Id'}, 'Track' {'WhatId'} -> 'What' {'Id'}'.</p>
</blockquote>

<p>I would like to say... yes, I know but...</p>

<p>Is such a configuration doable with EF Core ?</p>