How should I go about updating a row in the database? There is no update method, and if I use add and the primary key id already exists, I get an exception. Please provide an example if possible.
相关问题
- Entity Framework Code First Migration
- Entity Framework throws exception - Network Relate
- How to Specify a Compound key in Entity Framework
- Slow loading first page - ASP.NET MVC
- query and create objects with a one to many relati
相关文章
-
EF6 DbSet
returns null in Moq - Entity Framework 4.3.1 failing to create (/open) a
- EF6 code first: How to load DbCompiledModel from E
- Why do I need a ToList() to avoid disposed context
- Code-First Add-Migration keeps adding the same col
- EF Codefirst validate unique property?
- EF Core 'another instance is already being tra
- Add XML documentation / comments to properties/fie
The easiest way is:
(1) retrieve existing row using pk.
(2) update properties.
(3) call SaveChanges() on context.
e.g.
Here is a way that worked for me without having to make a query first: