How do I upsert a record in ADO.NET EF 4.1?

后端 未结 5 1958
走了就别回头了
走了就别回头了 2021-01-01 23:22

I\'m trying to accomplish something really simple and I can\'t find how to do it using Entity Framework 4.1.

I want a controller method that accepts an object and

5条回答
  •  离开以前
    2021-01-01 23:49

    actually there is a way to informa db context that entity you are trying to insert is changed and now the new one

    _context.MyEntity.Attach(entity);
    _context.MyEntity(entity).State = System.Data.EntityState.Modified;
    

提交回复
热议问题