Add() đánh dấu entity là mới (INSERT khi SaveChanges). Update() đánh dấu là đã sửa đổi (UPDATE). Attach() thêm vào context mà không đánh dấu modified — chỉ lưu khi properties thực sự thay đổi.
Dùng Add cho entity mới, Update cho detached entity cần thay thế toàn bộ, Attach cho batch updates có chọn lọc.
Add() marks the entity as new (INSERT on SaveChanges). Update() marks it as modified (UPDATE). Attach() adds to the context without marking modified — only saves when properties actually change.
Use Add for new entities, Update for detached entities you are replacing entirely, Attach for selective batch updates.