DB config WellOperations add OnDelete = SetNull behavior

This commit is contained in:
ngfrolov 2023-09-28 10:59:13 +05:00
parent bd0fd747af
commit a8f7dbc4f4
Signed by: ng.frolov
GPG Key ID: E99907A0357B29A7
5 changed files with 8705 additions and 2 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace AsbCloudDb.Migrations
{
public partial class WellOperations_Add_OnDelete_SetNull_Behavior : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_well_operation_t_well_operation_id_plan",
table: "t_well_operation");
migrationBuilder.AddForeignKey(
name: "FK_t_well_operation_t_well_operation_id_plan",
table: "t_well_operation",
column: "id_plan",
principalTable: "t_well_operation",
principalColumn: "id",
onDelete: ReferentialAction.SetNull);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_t_well_operation_t_well_operation_id_plan",
table: "t_well_operation");
migrationBuilder.AddForeignKey(
name: "FK_t_well_operation_t_well_operation_id_plan",
table: "t_well_operation",
column: "id_plan",
principalTable: "t_well_operation",
principalColumn: "id");
}
}
}

View File

@ -8408,7 +8408,8 @@ namespace AsbCloudDb.Migrations
b.HasOne("AsbCloudDb.Model.WellOperation", "OperationPlan")
.WithMany()
.HasForeignKey("IdPlan");
.HasForeignKey("IdPlan")
.OnDelete(DeleteBehavior.SetNull);
b.HasOne("AsbCloudDb.Model.Well", "Well")
.WithMany("WellOperations")

View File

@ -277,6 +277,11 @@ namespace AsbCloudDb.Model
{
entity.HasIndex(d => d.DepthEnd);
entity.HasIndex(d => d.DateStart);
entity.HasOne(o => o.OperationPlan)
.WithMany()
.HasForeignKey(o => o.IdPlan)
.OnDelete(DeleteBehavior.SetNull);
});
modelBuilder.Entity<DrillingProgramPart>(entity =>

View File

@ -66,7 +66,7 @@ namespace AsbCloudDb.Model
[JsonIgnore]
[ForeignKey(nameof(IdPlan))]
public virtual WellOperation OperationPlan { get; set; } = null!;
public virtual WellOperation? OperationPlan { get; set; } = null!;
}
}