none
Using merge with EF RRS feed

  • Question

  • I am using sql azure as storage.

    i have data (list of entities) which have both new and old records. i have no way to identify which recored is for update or insert. i need a way using EF to send the whole to thing to db and using some statement which will identity what to do with it (mean update or insert)

    please if you need to ask anything to clearfy please do so.

    Regards,

    Haroon.  

    Thursday, November 8, 2012 5:09 PM

All replies

  • Hi Haroon,

    Welcome to the MSDN forum.

    Why do you need to identify which is inserted and which is updated? If the data is tracked by Entity Framework, Entity Framework can identify them and generate the corresponding inset or update statements.

    Best Regards,


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 9, 2012 8:21 AM
  • Hi Alexander, Thanks for your reply.

    the thing is data is being loaded from csv file and thats why i dont have any tracking on it. so i need to either attach or add . and the problem i dont have a way to know what should i do.

    do we have any merge statment kind of statement in there ?

    any help will be helpful.

    Friday, November 9, 2012 9:26 AM
  • Hi Haroon,

    Sorry for delayed response.

    Please check this article: http://blog.oneunicorn.com/2012/05/03/the-key-to-addorupdate/

    Have a nice day.


    Alexander Sun [MSFT]
    MSDN Community Support | Feedback to us

    Thursday, November 22, 2012 7:47 AM
  • I would check this article:

    http://www.entityframeworktutorial.net/EntityFramework4.3/update-many-to-many-entity-using-dbcontext.aspx

    This blog is really good with "connected" vs "disconnected" scenarios.

    The url above shows that EF does not have a '.Merge' function (like NHibernate does)....you have to manually determine what got added/(stayed the same)/deleted.  Plus One to NHibernate.  I hope EF gets this fixed.  It's a big deal.

    Monday, April 14, 2014 7:29 PM