EFCore Base entity model properties with private setters - migration bizarre behavior
<p>It seems private setters inside classes that entity models inherit from cause bizarre issues with EFCore migrations. Consider the following example, where there are multiple classes (<code>Bar</code> and <code>Baz</code>) that inherit from <code>Foo</code>. When running <code>Add-Migration</code> commands multiple times (add/remove the <code>private</code> modifier`), the generated schema is just wrong in multiple ways.</p>

<ul>
<li>Sometimes the <code>Created</code> property is set to be a dropped column</li>
<li>Sometimes <em>all</em> the the <code>Created</code> properties are set to be removed (and not replaced/renamed with anything).</li>
</ul>

<p>It's my understanding that EFCore tools don't really treat properties with private setters with any special care. Is this a wrong assumption? If so, why do <em>some</em> private setters work on base classes, but not others? I'm assuming this is a bug in the EF Tools, perhaps related to how it treats naming on properties, considering I have other properties with similar names in the model which might be confusing the tools</p>

<pre><code>public class Context : DbContext
{
    public DbSet&lt;Bar&gt; Bars { get; set; }
    public DbSet&lt;Baz&gt; Bazs { get; set; }
}

public class Bar : Foo { }
public class Baz : Foo { }
public abstract class Foo
{
    protected Foo()
    {
        Created = DateTimeOffset.UtcNow;
    }
    public DateTimeOffset? Created { get; private set; }
    public DateTimeOffset? Updated { get; set; }
}
</code></pre>

<p>Edit -> It seems private setters for DateTimeOffset cause EF Tools to never map them in base classes. However, I have a string property with a private setter with <code>[Required]</code> and <code>[StringLength]</code> attributes, along with <code>builder.Entity&lt;Foo&gt;().HasAlternateKey(x =&gt; x.RequiredStringProperty);</code> In that case, EF absolutely maps the property...but only with some of the classes that are inheriting from <code>Foo</code>.</p>