title: Entity Framework Code First seeding entities having user id foreign key
body: <p>Here is my two entities and context classes:</p>
  
  <pre><code>public class ApplicationUser : IdentityUser
  {
      [Required]
      public string FirstName { get; set; }
  
      [Required]
      public string LastName { get; set; }
  
      [Required]
      public string Email { get; set; }
  }
  
  public class Event
  {
      public Guid Id { get; set; }
  
      [Required]
      public string Header { get; set; }
  
      [Required]
      public string Description { get; set; }
  
      [Required]
      public DateTime Date { get; set; }
  
      [Required]
      public ApplicationUser Host { get; set; }
  }
  
  public class ApplicationDbContext : IdentityDbContext&lt;ApplicationUser&gt;
  {
      public DbSet&lt;Event&gt; Events { get; set; }
  
      public ApplicationDbContext()
          : base("DefaultConnection")
      {
      }
  }
  </code></pre>
  
  <p>And here is my seed method:</p>
  
  <pre><code>protected override void Seed(ApplicationDbContext context)
      {
          var manager = new UserManager&lt;ApplicationUser&gt;(
              new UserStore&lt;ApplicationUser&gt;(
                  new ApplicationDbContext()));
  
          var user0 = new ApplicationUser()
          {
              UserName = "User0",
              FirstName = "FirstName0",
              LastName = "LastName0",
              Email = "Email0@Example.com",
          };
          manager.Create(user0, "Password0");
  
          var user1 = new ApplicationUser()
          {
              UserName = "User1",
              FirstName = "FirstName1",
              LastName = "LastName1",
              Email = "Email1@Example.com",
          };
          manager.Create(user1, "Password1");
  
          var user2 = new ApplicationUser()
          {
              UserName = "User2",
              FirstName = "FirstName2",
              LastName = "LastName2",
              Email = "Email2@Example.com",
          };
  
          var eventObj = new Event()
          {
              Id = Guid.NewGuid(),
              Host = user0,
              Header = "Header0",
              Description = "Description0",
              Date = DateTime.Now
          };
          manager.Create(user2, "Password2");
  
          context.Events.AddOrUpdate(eventObj);
      }
  </code></pre>
  
  <p>When I run the command <strong>Update-Database</strong> in Package Manager Console, I'm getting the following result:</p>
  
  <blockquote>
    <p>Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.</p>
  </blockquote>
  
  <p>What am I doing wrong? I'm working on VS 2013 Asp.net Mvc template.</p>
  
  <p>Thanks in advance,</p>