Open Closed

Add Migration with ABPSUITE ERROR #2098


User avatar
1
gvnuysal created
  • ABP Framework version: v4.3
  • UI type: Angular
  • DB provider: EF Core
    • Tiered (MVC) or Identity Server Separated (Angular): no
  • Exception message and stack trace:
  • Steps to reproduce the issue:"

Hi support, When I create a migration with Abp Suite, it creates the associated data as OnCascade. How can you set it as NoAction by default? When you do OnCascade, when the master data is deleted, it also deletes the child data attached to it. It should not be like this. The NoAction operation should be added to the code generator by default.

Code Example:

 //Built with Abp Suite
 builder.Entity<DeviceResult>(b =>
            {
                b.ToTable("DeviceResults", AbpViewConsts.GetSchemaName("Laboratory.DeviceResults"));
                b.ConfigureByConvention();
                b.Property(x => x.TenantId).HasColumnName(nameof(DeviceResult.TenantId));
                b.Property(x => x.Ip).HasColumnName(nameof(DeviceResult.Ip)).HasMaxLength(DeviceResultConsts.IpMaxLength);
                b.Property(x => x.Result).HasColumnName(nameof(DeviceResult.Result)).IsRequired();
                b.Property(x => x.Description).HasColumnName(nameof(DeviceResult.Description)).HasMaxLength(DeviceResultConsts.DescriptionMaxLength);
                b.Property(x => x.UserName).HasColumnName(nameof(DeviceResult.UserName)).HasMaxLength(DeviceResultConsts.UserNameMaxLength);
                b.Property(x => x.EntryDate).HasColumnName(nameof(DeviceResult.EntryDate)).IsRequired();
                b.Property(x => x.Id1).HasColumnName(nameof(DeviceResult.Id1)).HasMaxLength(DeviceResultConsts.Id1MaxLength);
                b.Property(x => x.Id2).HasColumnName(nameof(DeviceResult.Id2)).HasMaxLength(DeviceResultConsts.Id2MaxLength);
                b.Property(x => x.Id3).HasColumnName(nameof(DeviceResult.Id3)).HasMaxLength(DeviceResultConsts.Id3MaxLength);
                b.HasOne<DeviceDefination>().WithMany().IsRequired().HasForeignKey(x => x.DeviceDefinationId);
            });

In the above example, when you try to delete DeviceDefination due to OnCascade feature, it also deletes deviceResult information.

    b.HasOne<DeviceDefination>().WithMany().IsRequired().HasForeignKey(x => x.DeviceDefinationId).OnDelete(DeleteBehavior.NoAction);
    
    //When creating data associated with the Suite, the .OnDelete(DeleteBehavior.NoAction) property should be added by default.

3 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Maybe we can make DeleteBehavior configurable.

  • User Avatar
    0
    murat.in created

    Hi maliming. thanks for the answer. CascadeDelete is an often obsolete option in database designs. It risks deleting data from many tables in the database with a single delete command. This design is giving us a huge problem right now. We manually change the modelCreationExtension file that we created with ABP Suite, but it is not sustainable. We request you to consider this issue in the suite update. thanks.

  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    I will feedback to the Team.

Made with ❤️ on ABP v9.1.0-preview. Updated on December 13, 2024, 06:09