arch / AutoHistory

A plugin for Microsoft.EntityFrameworkCore to support automatically recording data changes history.
MIT License
779 stars 109 forks source link

Extended DbContextExtensions with "EnsureAddedHistory". #56

Closed NormanGiHu closed 3 years ago

NormanGiHu commented 3 years ago

This is how i use the new extension methods to write history for added entries. Perhaps other people can use this too.

Usage Example:

var addedEntries = dbContext.ChangeTracker .Entries() .Where(e => e.State == EntityState.Added) .ToArray(); dbContext.EnsureAutoHistory(); dbContext.SaveChanges(); dbContext.EnsureAddedHistory(addedEntries); dbContext.SaveChanges();

rigofunc commented 3 years ago

thks