asp.net - Designing classes in code first Entity Framework -


i building online shopping web application. have 4 entities :

  1. customers
    • cusomerid
    • name
    • address
    • phone
  2. category
    • categoryid
    • category
  3. product
    • productid
    • name
    • price
    • category
  4. order
    • orderid
    • customerid
    • productid
    • quantity
    • amount

please me designing classes proper relation(primary key , foreign key) maintained. tried doing database creating foreign key lead inconsistency.

my classes:

public class category     {         public int categoryid { get; set; }     public string categoryname { get; set; }     }  public class customer     {         public int customerid { get; set; }     public string name { get; set; }     public string address { get; set; }     public string  email { get; set; }     public string  password { get; set; }     }  public class order     {         public int customerid { get; set; }     public int orderid { get; set; }     public datetime purchasedate { get; set; }     public string productname { get; set; }     public list<product> products { get; set; }     public list<customer> customers { get; set; }     }  public class product     {         public int productid{ get; set; }     public string productname { get; set; }     public int price { get; set; }     public string category { get; set; }     public list<category> categories { get; set; }     } 

the problem in deciding should made primary key , foreign key , how? database adding order_orderid field in product table foreign key, itself.

your problem using list<product> products in side order. my understand property should not here. should create table orderitem contains list<product> product. can download northwind database more understand.

comeback problem. should remove list<product> products property out of class order , regenerate database.


Comments

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -