This question is locked. New answers and comments are not allowed.
Hi everyone,
I can't find the solution for the following problem..
I have Three Classes, all this making the reverse mapping and all the Id are identity in the tables.
-Ticket
Id
Name
-ItemInTicket
Id
TicketId
ItemId
Quantity
-ProfessionalInTicket
Id
TicketId
ProfessionalId
Approved
When I try to make this:
And I get a exception with the id from Ticket in ItemInTicket and ProfessionalInTicket.
Sql Server Profiler show me that the Ticket insert is done but when try to insert ItemInTicket the Id of TicketId is 0.
Could someone help me on this.
Thanks in advance.
I can't find the solution for the following problem..
I have Three Classes, all this making the reverse mapping and all the Id are identity in the tables.
-Ticket
Id
Name
-ItemInTicket
Id
TicketId
ItemId
Quantity
-ProfessionalInTicket
Id
TicketId
ProfessionalId
Approved
When I try to make this:
var oTicket =
new
Ticket();
oTicket.Name =
"Problem"
;
var oItem =
new
ItemInTicket();
oItem.ItemId = 8;
oItem.Quantity = 10;
oTicket.Items.Add(oItem);
var oProfessional =
new
ProfessionalInTicket();
oProfesional.ProfessionalId = 2;
oProfesional.Approved =
true
;
oTicket.Professionals.Add(oProfessional);
_context.Add(oTiket);
_context.SaveChanges()
And I get a exception with the id from Ticket in ItemInTicket and ProfessionalInTicket.
Sql Server Profiler show me that the Ticket insert is done but when try to insert ItemInTicket the Id of TicketId is 0.
Could someone help me on this.
Thanks in advance.