7 - Automatic Change Tracking in Entity Framework

preview_player
Показать описание
Entity framework is able to track the changes made to entities, so the correct updates are made on the database when the SaveChanges method of context is called.
The Change Tracking tracks changes while adding new records to the entity collections, modifying or removing existing entities.
Every entity must have EntityKey (primary key) property in order to be tracked by the context. Entity framework will not add any entity in the conceptual model which does not have an EntityKey property.
DbChangeTracker class gives you all the information about current entities being tracked by the context.
Рекомендации по теме
Комментарии
Автор

You explained it very nicely. I like your presentation. I've subscribed your channel. Please continue posting such nice tutorials..

rahulnikate
Автор

The instance of entity type 'Item' cannot be tracked because another instance with the same key value for {'Id'} is already being tracked Ask Question

dileepkumarkaranki
Автор

Hi, to your code, can I run savechanges() at the end to make all the add, update and delete commands work ?? or should I use 3 seperate savechanges() calls for each?

sumanthdarisi
Автор

nice video thanks for your effort, i have a question, can i make a log table that tracking the changes u mentioned but also with the old and the new values with the date?

mohamedhossam