Note that there are some explanatory texts on larger screens.

plurals
  1. POPossible Bug in Migration for EF 6 Alpha 3 on recursive relationship?
    primarykey
    data
    text
    <p>I had to define a recursive relationship on a composite key. After much trials, I ended up with this:</p> <pre><code>protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); modelBuilder.Entity&lt;Category&gt;() .Property(t =&gt; t.WhichAmazon).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None); modelBuilder.Entity&lt;Category&gt;() .Property(t =&gt; t.IdCategory).HasDatabaseGeneratedOption(DatabaseGeneratedOption.None); modelBuilder.Entity&lt;Category&gt;() .HasKey(c =&gt; new {c.WhichAmazon, c.IdCategory}) .HasOptional(p =&gt; p.Children) .WithMany() .HasForeignKey(c =&gt; new { c.WhichChildrenAmazon, c.ChildrenId }); } </code></pre> <p>for this table</p> <pre><code>public class Category { // Keys and relationships defined in BooksDataLayer [MaxLength(2)] public string WhichAmazon { get; set; } public int IdCategory { get; set; } public string Name { get; set; } [Timestamp] public Byte[] TimeStamp { get; set; } public DateTime LastCheck { get; set; } public virtual List&lt;Book&gt; Books { get; set; } public string WhichChildrenAmazon { get; set; } public int? ChildrenId { get; set; } public virtual List&lt;Category&gt; Children { get; set; } } </code></pre> <p>While trying to Add-Migration I was constantly having the same error: "Sequence contains no elements". As I was "almost" sure this definition was right, I went ahead a re-created a new Db, WITHOUT migration. Was perfectly OK, no problems with the Db at all. So there is "something" in there which EF 6 does not like. I had a confirmation, as EF power tools bombs if I try to get a schema "Exception has been thrown by the target of an invocation". </p> <p>I'll see what happens now with migration if I restart from there, but I am afraid to not be able to use anymore with this Db. I do like the tool, a lot, so I hope this can be fixed.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload