A ChangeSource property can be added and populated on your change entities, to store where change occured from.

  1. Implement the IHasChangeSource<TChangeSource> interface on your change entity (ChangeSource is an enum in this example):
    public class UserChange : IChange<User>, IHasChangeSource<ChangeSource>
    {
    ...
    
  2. Create a ChangeSourceProvider by inheriting the ChangeSourceProvider<TChangeSource> class and overriding the required method(s):
    public class MyChangeSourceProvider : ChangeSourceProvider<ChangeSource>
    {
     public override <ChangeSourceType> GetChangeSourceAsync()
     {
         return Task.FromResult(ChangeSource.ConsoleApp);
     }
    }
    
  3. Add the UseChangeSource<TChangeSourceProvider, TChangeSource>() option to your DbContextOptions, specifying your ChangeSourceProvider and ChangeSource type:
    services.AddDbContext<MyDbContext>(options =>
    {
     options
         .UseSqlServerChangeTriggers(options =>
         {
             options.UseChangeSource<MyChangeSourceProvider, ChangeSource>()
         });
    }
    
  4. Create a migration if required:
    dotnet ef migrations add ChangeSource
    

Table of contents