asp.net mvc 5 - Creating Model for two different tables already existent - MVC 5 -


i have problem using mvc.

i created model name po_header purchase order header , other model name po_detail purchase order details.

the problem have both tables created in database, po_header , po_detail how create 1 controller , views both tables?

they in different tables need add them in same form when click create/add, both tables updated.

model po_header:

[table("po_header")] public class po_header {     [key]     [displayname("número pedido")]     public string ponumber { get; set; }      [displayname("cliente")]     public int customerid { get; set; }     [foreignkey("customerid")]     public virtual customers customers { get; set; }      [displayname("expedidor")]     public string shipper { get; set; }      [displayname("rta")]     [datatype(datatype.datetime)]     [displayformat(dataformatstring = "{0:dd/mm/yyyy}", applyformatineditmode = true)]     public datetime rta { get; set; }      [displayname("data de envio")]     [datatype(datatype.datetime)]     [displayformat(dataformatstring = "{0:dd/mm/yyyy}", applyformatineditmode = true)]     public datetime senddate { get; set; }      [displayname("data de criação")]     [datatype(datatype.datetime)]     [displayformat(dataformatstring = "{0:dd/mm/yyyy}", applyformatineditmode = true)]     public datetime createdate { get; set; }      [displayname("li")]     public int li_number { get; set; } } 

model po_detail:

[table("po_detail")] public class po_detail {     [displayname("número pedido")]     public string ponumber { get; set; }     [foreignkey("ponumber")]     [column(order = 1)]     public virtual po_header poheader { get; set; }      [key]     [column(order = 2)]     [displayname("part number")]     public string partnumber { get; set; }      [key]     [column(order = 3)]     [displayname("line number")]     public int linenumber { get; set; }      [displayname("fabricante")]     public int makerid { get; set; }     [foreignkey("makerid")]     public virtual makers makers { get; set; }      [displayname("anuente")]     public bool anuente { get; set; }      [displayname("quantidade")]     public int quantity { get; set; }      [displayname("fornecedor")]     public int supplierid { get; set; }     [foreignkey("supplierid")]     public virtual suppliers suppliers { get; set; }      [displayname("valor unitário")]     public decimal? unitprice { get; set; }      [displayname("valor total")]     public decimal? totalprice { get; set; }      [displayname("moeda")]     public int moedaid { get; set; }     [foreignkey("moedaid")]     public virtual sigla_moeda siglamoeda { get; set; } } 


Comments

Popular posts from this blog

java - nested exception is org.hibernate.exception.SQLGrammarException: could not extract ResultSet Hibernate+SpringMVC -

sql - Postgresql tables exists, but getting "relation does not exist" when querying -

asp.net mvc - breakpoint on javascript in CSHTML? -