-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Scaffolding: not adding HasTrigger #30253
Comments
Duplicate of #10770 |
Although EF has infrastructure for managing triggers, it doesn't yet actually support them for SQL Server/SQLite. #10770 tracks that. |
@roji this is about reverse engineering, not migrations |
Sure, but i think we'd do both in the same work item, that's pretty standard. But no objection to track separately. |
But scaffolding already attempts to Detect triggers AFAIK. So I think this an edge case of side effects from a trigger. |
Don't think this is a duplicate, as to me it is a bug to an existing scaffolding feature, the linked issue is about adding a feature to migration. imho they might be related, but not a duplicate. |
@lsiepel I am not able to reproduce this. With that schema, I get the following model configuration. It includes protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Autorisatie>(entity =>
{
entity.HasKey(e => e.IdAutorisatie).HasName("PK_Autorisatie_idAutorisatie");
entity.ToTable("Autorisatie");
entity.HasIndex(e => new { e.AutorisatieOnderdeelId, e.GebruikersgroepId }, "UQ_AutorisatieOnderdeel_Gerbuikersgroep").IsUnique();
entity.Property(e => e.IdAutorisatie).HasColumnName("idAutorisatie");
entity.HasOne(d => d.AutorisatieOnderdeel).WithMany(p => p.Autorisaties)
.HasForeignKey(d => d.AutorisatieOnderdeelId)
.OnDelete(DeleteBehavior.ClientSetNull)
.HasConstraintName("FK_Autorisatie_idAutorisatieOnderdeel");
entity.HasOne(d => d.Gebruikersgroep).WithMany(p => p.Autorisaties)
.HasForeignKey(d => d.GebruikersgroepId)
.HasConstraintName("FK_Autorisatie_idGebruikersgroep");
});
modelBuilder.Entity<AutorisatieOnderdeel>(entity =>
{
entity.HasKey(e => e.IdAutorisatieOnderdeel).HasName("PK_Rol_idRol");
entity.ToTable("AutorisatieOnderdeel", tb => tb.HasTrigger("TRG_AutorisatieOnderdeel_insert"));
entity.HasIndex(e => e.IdAutorisatieOnderdeel, "UQ_AutorisatieOnderdeel_Naam").IsUnique();
entity.Property(e => e.IdAutorisatieOnderdeel).HasColumnName("idAutorisatieOnderdeel");
entity.Property(e => e.Naam)
.HasMaxLength(40)
.IsUnicode(false);
});
modelBuilder.Entity<Gebruikersgroep>(entity =>
{
entity.HasKey(e => e.Id).HasName("PK_Gebruikersgroep_idRolgroep");
entity.ToTable("Gebruikersgroep", tb => tb.HasTrigger("TRG_Gebruikersgroep_insert"));
entity.HasIndex(e => e.Naam, "UQ_Gebruikersgroep_Naam").IsUnique();
entity.Property(e => e.Naam)
.HasMaxLength(25)
.IsUnicode(false);
});
OnModelCreatingPartial(modelBuilder);
} |
EF Team Triage: Closing this issue as the requested additional details have not been provided and we have been unable to reproduce it. BTW this is a canned response and may have info or details that do not directly apply to this particular issue. While we'd like to spend the time to uniquely address every incoming issue, we get a lot traffic on the EF projects and that is not practical. To ensure we maximize the time we have to work on fixing bugs, implementing new features, etc. we use canned responses for common triage decisions. |
According to ErikEJ/EFCorePowerTools#1688 i should raise this issue here. When using the EFCorePowerTools the scaffolding does not detect/pick-up a trigger resulting in the absence of
HasTrigger
when creating the model.DB schema in SQL server: https://1drv.ms/u/s!AnMcxmvEeupwjqVc431dzHgq-GUX6Q?e=zzLDvA
Contains three tables:
Gebruikersgroep
andAutorisatieonderdeel
both holding a trigger that performs actions against tableAutorisatie
Versions:
EF Core version in use: EF Core 7.0.2
Is Handlebars used: yes
Is T4 used: no
Is .dacpac used: no
EF Core Power Tools version: 2.5.1277
Database engine: SQL Server
Visual Studio version: Visual Studio 2022
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (e.g. .NET 6.0)
The text was updated successfully, but these errors were encountered: