Upgrade POCO Environment to EF6 RRS feed

  • Question

  • We just upgraded our VB.Net, WPF, MVVM, EF4.0, ObjectContext, POCO, disconnected environment to EF6.  We were using the ADO.Net Poco generator which generated the classes that handle the foreign key assignment fix up.  After generating our classes with the new EF6 entity tt code this is no longer done.  Now, when assigning a new child object to an existing parent object via the foreign entity property and then doing an Attach a RI constraint error is thrown (if its a required association) or the object gets saved without the foreign key set (if its not a required association).  This all worked prior to upgrading to EF6.  Can someone please shed some light on the easiest way to upgrade this kind of EF4.0 project to EF6?  Thank you in advance for any help!!

    ParentId INT
    ParentName VARCHAR(20)

    ChildId INT
    ParentId INT
    ChildName VARCHAR(20)
    Parent ParentObject

    Dim p as new ParentObject
    p=_context.Parents.Where(function(x) x.ParentId=5).First
    Dim c as new ChildObject
    Error is thrown here about a referential constraint error.


    • Edited by HeatherNo Friday, May 16, 2014 11:33 AM
    Friday, May 16, 2014 1:50 AM


  • Hello,

    >>Error is thrown here about a referential constraint error.

    Could you please share the details error information with us since there are several referential constraint errors?

    With your codes, I also made a demo as below with C#:             

    Order order = db.Orders.FirstOrDefault();
                        OrderDetail orderDetail = new OrderDetail() { OrderDetailID = 1, OrderDetailName = "3", OrderID = 1 };
                        orderDetail.Order = order;
    I think the only difference is that I assign the foreign key when initializing the child instance OrderID = 1, you can have a try to assign the foreign key firstly.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Fred Bao Tuesday, May 27, 2014 5:45 AM
    Monday, May 19, 2014 2:32 AM