Keys on Derived Type...But It's Not
<p>I'm new to EF7, and am running into a strange problem. I have this class:</p>

<pre><code>public class Site
{
    public int ID { get; set; }
    public string Title { get; set; }
    public string HouseNumber { get; set; }
    public string StreetName { get; set; }
    public string City { get; set; }
    public string State { get; set; }
    public string Zipcode { get; set; }
    public double Latitude { get; set; }
    public double Longitude { get; set; }
    public DataSource Source { get; set; }

    public object Parameters
    {
        get
        {
            switch( Source )
            {
                case DataSource.StealthStats:
                    return JsonConvert.DeserializeObject&lt;StealthStatsParameters&gt;( JSONParameters );

                default:
                    throw new Exception( "Site::Parameters::get() - Unhandled DataSource " + Source.ToString() );
            }
        }

        set
        {
            switch( Source )
            {
                case DataSource.StealthStats:
                    JSONParameters = JsonConvert.SerializeObject( value );
                    break;

                default:
                    throw new Exception( "Site::Parameters::set() - Unhandled DataSource " + Source.ToString() );
            }
        }
    }

    protected string JSONParameters { get; set; }

    public List&lt;Observation&gt; Observations { get; set; }
}
</code></pre>

<p>and this logic in the context's OnModelCreating():</p>

<pre><code>protected override void OnModelCreating(ModelBuilder builder)
{
    base.OnModelCreating(builder);
    // Customize the ASP.NET Identity model and override the defaults if needed.
    // For example, you can rename the ASP.NET Identity table names and more.
    // Add your customizations after calling base.OnModelCreating(builder);

    builder.Entity&lt;Site&gt;()
        .HasKey( t =&gt; t.ID );
    builder.Entity&lt;Site&gt;()
        .Property( s =&gt; s.City )
        .IsRequired();
    builder.Entity&lt;Site&gt;()
        .Property( s =&gt; s.HouseNumber )
        .IsRequired();
    builder.Entity&lt;Site&gt;()
        .Property( s =&gt; s.Source )
        .IsRequired();
    builder.Entity&lt;Site&gt;()
        .Property( s =&gt; s.State )
        .IsRequired()
        .HasMaxLength( 2 );
    builder.Entity&lt;Site&gt;()
        .Property( s =&gt; s.StreetName )
        .IsRequired();
    builder.Entity&lt;Site&gt;()
        .Property( s =&gt; s.Title )
        .IsRequired();
    builder.Entity&lt;Site&gt;()
        .Property( s =&gt; s.Zipcode )
        .IsRequired()
        .HasMaxLength( 10 );

    builder.Entity&lt;Observation&gt;()
        .HasKey( t =&gt; new { t.SiteID, t.TimeStamp } );
    builder.Entity&lt;Observation&gt;()
        .HasOne( o =&gt; o.Site )
        .WithMany( s =&gt; s.Observations );

}
</code></pre>

<p>But when I run dnx ef migrations add, I get this error message:</p>

<blockquote>
  <p>The derived type 'SpeedView.Models.Site' cannot have keys other than those declared on the root type.</p>
</blockquote>

<p>Yet so far as I can see, Site is not derived from anything.</p>

<p>BTW, here's the definition for the class Observation, in case that's important:</p>

<pre><code>public class Observation
{
    public int SiteID { get; set; }

    public DateTime TimeStamp { get; set; }

    public int MPH { get; set; }

    public int VehicleCount { get; set; }

    public virtual Site Site { get; set; }
}
</code></pre>

<p>As an aside, if anyone can recommend some links to good tutorials and explanations of EF7 I would appreciate that. I'm finding the learning curve on it, after working with EF for years, to be very steep, and the stuff I've found online isn't terribly helpful.</p>