Spin up a SqlServer
docker compose up -d --buildPort: 5174 Login: sa / password123!
dotnet build DbAuditWithEF.slnx
dotnet test DbAuditWithEF.slnxcd DbAuditWithEF.DatabaseTrigger
# Install
dotnet tool install --global dotnet-ef
# Create
dotnet ef migrations add InitialCreate
dotnet ef database update
# Delete
dotnet ef migrations remove
dotnet ef database drop -f- DatabaseTrigger: Set CreatedBy/On and ModifiedBy/On with a database trigger.
- ByEF: Same but set with Entity Framework. Use a ComplexType
IAuditand overwrite manual changes to the properties. - ByInterceptor: Same as ByEF but using a
SaveChangesInterceptorfor better separation of concerns. - ByReflection: Totally avoid setting the properties manually by making them private and using reflection.
- DatabaseTable: Keep changes in a separate table with a database trigger.
- EFTable: Same but insert records with Entity Framework.