EntityTypeBuilder<T>.HasTrigger("My Trigger")
See original GitHub issueHi so we have to declare that our tables have triggers in EF 7 in order to get Inserts to work.
It seems this has to be done using the ModelBuilder as so…
modelBuilder.Entity<Blog>()
.ToTable(tb => tb.HasTrigger("SomeTrigger"));
I would have liked to do this inside the Configure method of my IEntityTypeConfiguration<T> classes however there’s no HasTrigger method available on EntityTypeBuilder<T>. Would it be possible to add this method?
Also if a table has multiple triggers do we have to declare each of these? If so how do you do this?
Issue Analytics
- State:
- Created 7 months ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Entity Framework 6 / SQL Server triggers - getting error
The error is actually telling you that you can't use an OUTPUT without an INTO clause, not "You cannot use triggers in Entity...
Read more >Triggers for Entity Framework Core - On The Drift
Triggered by default supports recursion which means that changes to your DbContext from within your triggers will be recorded and subsequent triggers will...
Read more >Add support for managing Triggers with EF migration #10770
So my question : Why ? Is there something difficult to manage with triggers ? Why could we add some custom operations on...
Read more >Breaking changes in EF Core 7.0 (EF7)
This effectively calls HasTrigger on all your model's tables, instead of you having to do it manually for each and every table. SQLite...
Read more >Entity Framework Community Standup - Triggers for EF Core
See how it is implemented and how the project uses EF Core's ChangeTracker and ... Entity Framework Community Standup - Triggers for EF...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@micktion the HasTrigger method isn’t on EntityTypeBuilder, it’s on the TableBuilder that’s inside the ToTable method. So you can define a trigger as follows:
Re multiple triggers… For now, HasTrigger doesn’t actually create the triggers - it’s simply a way to inform EF to use SQL that’s compatible with triggers (i.e. avoid the more efficient OUTPUT clause). So there’s no benefit in defining multiple triggers on the same table - just one should do the trick.
Guess I hadn’t…