Why can't I insert record with foreign key in a single server request?

后端 未结 3 967
走了就别回头了
走了就别回头了 2020-12-31 20:46

I\'m tryring to do a simple insert with foreign key, but it seems that I need to use db.SaveChanges() for every record insert. How can I manage to use only one

3条回答
  •  星月不相逢
    2020-12-31 20:56

    it might be related with the implementation of AddToSalesFeedSet etc.. there is chance that you are doing commit inside ?

    any way, my point is that i encountered very close problem, was tring to add relation to new entity with existed entity that been queried earlier - that has unsigned key and got the same exception;

    the solution was to call Db.collection.Attach(previouslyQueriedEntityInstance);

提交回复
热议问题