-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add triggers for generic types. #96
Comments
I'm having same issue. did you get any alternative? |
No. I needed to do it by another way. I created a static class that is executed when user executes database-update. My problem context is: I needed to create triggers whenever a table is created. My approach was: delete all triggers and recreate the triggers when user executes database-update.
And then on program.cs:
|
ahh I was thinking about taking a different approach. where i work with MigrationsModelDiffer class to create a static implementation for each table. which should trigger like this library. but i got a verry little success with it. i need to investigate the library to make it work. |
Added the method to help with generic trigger registration https://github.com/win7user10/Laraue.EfCoreTriggers/blob/master/tests/Laraue.EfCoreTriggers.Tests/Tests/GenericTriggersTests.cs#L53 |
var entities = modelBuilder.Model.GetEntityTypes().ToList();
entities.ForEach(entity =>
{
var entityType = entity.GetType();
var fks = entity.GetForeignKeys().ToList();
if(fks.Count == 0)
{
modelBuilder.Entity(entityType)/* EXTENSION METHODS HERE*/
}
});
Is there a way to create triggers by the sample code above? I actually know that using modelBuilder.Entity() is possible. But I would like to create a generic trigger generator.
The text was updated successfully, but these errors were encountered: