Исправлена миграция, с добавлением клиента, чтобы удалялись все заказы

This commit is contained in:
Данияр Аглиуллов 2023-03-08 14:40:41 +04:00
parent 257981c280
commit 8044cadda1
3 changed files with 81 additions and 80 deletions

View File

@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ConfectioneryDatabaseImplement.Migrations namespace ConfectioneryDatabaseImplement.Migrations
{ {
[DbContext(typeof(ConfectioneryDatabase))] [DbContext(typeof(ConfectioneryDatabase))]
[Migration("20230304103151_add_entity_client")] [Migration("20230307072144_add_client")]
partial class add_entity_client partial class add_client
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder) protected override void BuildTargetModel(ModelBuilder modelBuilder)

View File

@ -5,11 +5,12 @@
namespace ConfectioneryDatabaseImplement.Migrations namespace ConfectioneryDatabaseImplement.Migrations
{ {
/// <inheritdoc /> /// <inheritdoc />
public partial class add_entity_client : Migration public partial class add_client : Migration
{ {
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.Sql("DELETE FROM Orders");
migrationBuilder.AddColumn<int>( migrationBuilder.AddColumn<int>(
name: "ClientId", name: "ClientId",
table: "Orders", table: "Orders",

View File

@ -10,17 +10,17 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace ConfectioneryDatabaseImplement.Migrations namespace ConfectioneryDatabaseImplement.Migrations
{ {
[DbContext(typeof(ConfectioneryDatabase))] [DbContext(typeof(ConfectioneryDatabase))]
partial class ConfectioneryDatabaseModelSnapshot : ModelSnapshot partial class ConfectioneryDatabaseModelSnapshot : ModelSnapshot
{ {
protected override void BuildModel(ModelBuilder modelBuilder) protected override void BuildModel(ModelBuilder modelBuilder)
{ {
#pragma warning disable 612, 618 #pragma warning disable 612, 618
modelBuilder modelBuilder
.HasAnnotation("ProductVersion", "7.0.3") .HasAnnotation("ProductVersion", "7.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128); .HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b =>
{ {
@ -28,7 +28,7 @@ namespace ConfectioneryDatabaseImplement.Migrations
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO") b.Property<string>("ClientFIO")
.IsRequired() .IsRequired()
@ -59,21 +59,21 @@ namespace ConfectioneryDatabaseImplement.Migrations
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<double>("Cost") b.Property<double>("Cost")
.HasColumnType("float"); .HasColumnType("float");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Components"); b.ToTable("Components");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId") b.Property<int>("ClientId")
.HasColumnType("int"); .HasColumnType("int");
@ -81,75 +81,75 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("int");
b.Property<DateTime>("DateCreate") b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int>("PastryId") b.Property<int>("PastryId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("Status") b.Property<int>("Status")
.HasColumnType("int"); .HasColumnType("int");
b.Property<double>("Sum") b.Property<double>("Sum")
.HasColumnType("float"); .HasColumnType("float");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId"); b.HasIndex("ClientId");
b.HasIndex("PastryId"); b.HasIndex("PastryId");
b.ToTable("Orders"); b.ToTable("Orders");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("PastryName") b.Property<string>("PastryName")
.IsRequired() .IsRequired()
.HasColumnType("nvarchar(max)"); .HasColumnType("nvarchar(max)");
b.Property<double>("Price") b.Property<double>("Price")
.HasColumnType("float"); .HasColumnType("float");
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("Pastries"); b.ToTable("Pastries");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.PastryComponent", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd() .ValueGeneratedOnAdd()
.HasColumnType("int"); .HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ComponentId") b.Property<int>("ComponentId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("PastryId") b.Property<int>("PastryId")
.HasColumnType("int"); .HasColumnType("int");
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ComponentId"); b.HasIndex("ComponentId");
b.HasIndex("PastryId"); b.HasIndex("PastryId");
b.ToTable("PastryComponents"); b.ToTable("PastryComponents");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Order", b =>
{ {
@ -178,16 +178,16 @@ namespace ConfectioneryDatabaseImplement.Migrations
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry") b.HasOne("ConfectioneryDatabaseImplement.Models.Pastry", "Pastry")
.WithMany("Components") .WithMany("Components")
.HasForeignKey("PastryId") .HasForeignKey("PastryId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Component"); b.Navigation("Component");
b.Navigation("Pastry"); b.Navigation("Pastry");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Client", b =>
{ {
@ -199,13 +199,13 @@ namespace ConfectioneryDatabaseImplement.Migrations
b.Navigation("PastryComponents"); b.Navigation("PastryComponents");
}); });
modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b => modelBuilder.Entity("ConfectioneryDatabaseImplement.Models.Pastry", b =>
{ {
b.Navigation("Components"); b.Navigation("Components");
b.Navigation("Orders"); b.Navigation("Orders");
}); });
#pragma warning restore 612, 618 #pragma warning restore 612, 618
} }
} }
} }