Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hey I have not worked on phone development yet but it all comes to almost the same logic try to use the Fluent API which you can read more about in <a href="http://msdn.microsoft.com/en-us/data/jj591617.aspx" rel="nofollow">here</a></p> <p>now what you want to do is starting by making both of your classes <strong>public</strong> a lot of ppl working with this can forget it so that's why i have to say it but you have it already and thats good :) so a name can have many numbers(phones?)</p> <pre><code>namespace AddressBook.Models { public class Name { public Name () { PhoneList = new List&lt;Phone&gt;(); // just so you wont end up with a null reference if you have not yet provided any data. } public int NameID { get; set; } public string FirstName { get; set; } public string LastName { get; set; } //ref public virtual ICollection&lt;Phone&gt; Phones { get; set; } //added the virtual } } </code></pre> <p>now to your phone class</p> <pre><code>namespace AddressBook.Models { public class Phone { public Phone(){} public int ID { get; set; } public string Number { get; set; } public virtual Name Name { get; set; } } } </code></pre> <p>Now on you OnModelCrating you can say what's required and what has many of what :) something like this</p> <pre><code>Protected override void OnModelCrateing(DbModelBuilder modelBuilder) { mobelbuilder.Entity&lt;Name&gt;().HasRequired&lt;Phone&gt;.(n=&gt;n.ID).WithMany(n=&gt;n.PhoneList).HasForeignKey(n=&gt;n.NameID); } </code></pre> <p>something this nice should be good :)</p> <p>Have fun coding mate!</p> <p>Cheers!</p>
    singulars
    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