title: MVC Seed does not put data in the database
body: <p>I have two tables with a relation between them.</p>
  
  <p>Here are my models:</p>
  
  <pre><code>public  class Locations
  {
    [Key]
    public int LocationID { get; set; }
  
    [Required(ErrorMessage = "This field is required!")]
    [MaxLength(50, ErrorMessage = "The name is too long. Max. 50 characters allowed!")]
    [Display(Name = "Location name:")]
    public string Name { get; set; }
  
    public int Position { get; set; }
  
    public virtual LocationType LocationType { get; set; }
  
  }
  </code></pre>
  
  <p>and</p>
  
  <pre><code>public class LocationType
  {
    [Key]
    public int LocationTypeID { get; set; }
  
    [Required(ErrorMessage = "This field is required!")]
    [MaxLength(25, ErrorMessage = "The name is too long. Max. 25 characters allowed!")]
    [Display(Name = "Location type:")]
    public string Name { get; set; }
  
    public int Position { get; set; }
  
    public int HasChoicesOrInput { get; set; } 
  
    public virtual ICollection&lt;Locations&gt; Locations { get; set; }
  }
  </code></pre>
  
  <p>In my configuration.cs file I have the following seed:</p>
  
  <pre><code>context.LocationType.AddOrUpdate(a =&gt; a.LocationTypeID,
    new LocationType
    {
      Name = "AAAAA",
      HasChoicesOrInput = 1,
      Position = 1,
      Locations = { new Locations { Name = "1111111", Position = 1 },
                      new Locations { Name = "2222222", Position = 2 }
                  }
    });
  </code></pre>
  
  <p>Table definition:</p>
  
  <pre><code>CREATE TABLE [dbo].[Locations] (
  [LocationID]                  INT           IDENTITY (1, 1) NOT NULL,
  [Name]                        NVARCHAR (50) NOT NULL,
  [Position]                    INT           NOT NULL,
  [LocationType_LocationTypeID] INT           NULL,
  CONSTRAINT [PK_dbo.Locations] PRIMARY KEY CLUSTERED ([LocationID] ASC),
  CONSTRAINT [FK_dbo.Locations_dbo.LocationTypes_LocationType_LocationTypeID] FOREIGN KEY ([LocationType_LocationTypeID]) REFERENCES [dbo].[LocationTypes] ([LocationTypeID])
  );
  
  CREATE TABLE [dbo].[LocationTypes] (
  [LocationTypeID]    INT           IDENTITY (1, 1) NOT NULL,
  [Name]              NVARCHAR (25) NOT NULL,
  [Position]          INT           NOT NULL,
  [HasChoicesOrInput] INT           NOT NULL,
  CONSTRAINT [PK_dbo.LocationTypes] PRIMARY KEY CLUSTERED ([LocationTypeID] ASC)
  );
  </code></pre>
  
  <p>When I do an Update-Database, I get an "Object reference not set to an instance of an object." error.</p>
  
  <p>Why? The tables exist in the database, the relation too.
  What am I missing here?</p>