Adds trigger-like events (inserting, updating, deleting) to Entity Framework and Entity Framework Core entities.
EntityFramework.Triggers is a .NET library that adds trigger-like events to Entity Framework and Entity Framework Core entities. It allows developers to execute custom logic before, after, or upon failure of insert, update, and delete operations, solving the need for database-like triggers in the application layer.
.NET developers using Entity Framework or Entity Framework Core who need to implement cross-cutting concerns like auditing, logging, automatic timestamping, or soft deletes without modifying database schemas.
Developers choose EntityFramework.Triggers because it provides a clean, code-first way to implement trigger logic directly in the application layer, with full support for dependency injection and compatibility with existing DbContext classes.
Adds events for entity inserting, inserted, updating, updated, deleting, and deleted
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Provides before, after, and failure events for insert, update, and delete operations, enabling patterns like automatic timestamping and soft deletes, as demonstrated in the Trackable and SoftDeletable examples.
Allows cancellation of inserting, updating, and deleting events to implement patterns like soft deletes without database changes, evidenced by the Deleting event handler that sets entry.Cancel = true.
Fully integrates with ASP.NET Core DI, allowing services like IServiceBus to be injected into trigger handlers using entry.Service, as shown in the dependency injection usage section.
Supports both global triggers and per-entity or per-DbContext triggers, offering granular control over event logic, with examples for context-specific handling in the basic and DI usage.
Requires inheriting from DbContextWithTriggers or manually overriding all SaveChanges methods, which adds boilerplate code and complexity, especially for existing DbContext classes that can't change inheritance.
Operates at the application level, missing database-level trigger features like row-level locking or integration with stored procedures, which may be necessary for data integrity or performance.
Tightly coupled with Entity Framework, making it unsuitable for projects that might migrate to other ORMs or need cross-platform trigger logic, limiting long-term flexibility.