title: Unable to CodeFirst My DB EF 6.2 2 FK to one PK relation(MVC APP)
body: <p>I've been trying to code first and add migration to this code and couldn't understand what I'm doing wrong.
  keep in mind I'm trying to make an <code>MVC</code> App for placing and buying products.</p>
  
  <p>which means I got two models Products and Users, I cant figure out already how I 
  separate between non-registered account and registered accounts.</p>
  
  <p>I thought about making a function which may return -1 if not registered and the id of the account if registered but don't know how.</p>
  
  <p>this is My Code:</p>
  
  <pre><code> public class Products
  {
  
      [Required]
      public long Id { get; set; }
      public long UserId { get; set; }
      public long OwnerId { get; set; }
      [ForeignKey("OwnerId")]
      public Users Owner { get; set; }
      [ForeignKey("UserId")]
      public Users User { get; set; }
      public string Title { get; set; }
      public string ShortDescription { get; set; }
      public string LongDescription { get; set; }
      [Required]
      public DateTime Date { get; set; }
      public decimal Price { get; set; }
      [Column("Picture1", TypeName = "image")]
      public byte[] Picture1 { get; set; }
      [Column("Picture2", TypeName = "image")]
      public byte[] Picture2 { get; set; }
      [Column("Picture3", TypeName = "image")]
      public byte[] Picture3 { get; set; }
      public int State { get; set; }
  }
  </code></pre>
  
  <p>my Users class</p>
  
  <pre><code>public class Users
  {
      public long Id { get; set; }
      [Required]
      public string FirstName { get; set; }
      [Required]
      public string LastName { get; set; }
      [Required]
      public DateTime BirthDate { get; set; }
      [Required]
      public string Email { get; set; }
      [Required]
      public string UserName { get; set; }
      [Required]
      public string Password { get; set; }
  }
  </code></pre>
  
  <p>and DBContext:</p>
  
  <pre><code>public class SiteDBContext : DbContext
  {
      public SiteDBContext()
          : base("name =SiteDBContext")
      {
  
      }
  
      public DbSet&lt;Users&gt; Users { get; set; }
      public DbSet&lt;Products&gt; Products { get; set; }
      protected override void OnModelCreating(DbModelBuilder modelBuilder)
      {
          base.OnModelCreating(modelBuilder);
      }
  }
  </code></pre>
  
  <p>While I was trying to make a migration to this it cause this error:</p>
  
  <blockquote>
    <p>Introducing <code>FOREIGN KEY</code> constraint <code>'FK_dbo.Products_dbo.Users_UserId'</code> on table <code>'Products'</code> may cause cycles or multiple cascade paths. Specify <code>ON DELETE NO ACTION</code> or <code>ON UPDATE NO ACTION</code>, or modify other <code>FOREIGN KEY</code> constraints.
    Could not create constraint or index. See previous errors.</p>
  </blockquote>
  
  <p>Thanks to everyone, if there is some understandable info here please ask and I will explain better.
  thanks again!</p>
  
  <pre><code>CreateTable(
              "dbo.Products",
              c =&gt; new
                  {
                      Id = c.Long(nullable: false, identity: true),
                      OwnerId = c.Long(nullable: false),
                      UserId = c.Long(nullable: false),
                      Title = c.String(),
                      ShortDescription = c.String(),
                      LongDescription = c.String(),
                      Date = c.DateTime(nullable: false),
                      Price = c.Decimal(nullable: false, precision: 18, scale: 2),
                      Picture1 = c.Binary(storeType: "image"),
                      Picture2 = c.Binary(storeType: "image"),
                      Picture3 = c.Binary(storeType: "image"),
                      State = c.Int(nullable: false),
                  })
              .PrimaryKey(t =&gt; t.Id)
              .ForeignKey("dbo.Users", t =&gt; t.UserId, cascadeDelete: true)
              .ForeignKey("dbo.Users", t =&gt; t.OwnerId, cascadeDelete: true)
              .Index(t =&gt; t.OwnerId)
              .Index(t =&gt; t.UserId);
  </code></pre>
  
  <p>this is the migration created, and still cant update the database with error that may cause cycles or multiple cascade paths. anyone? </p>