миграция

This commit is contained in:
russell 2024-04-29 21:30:41 +04:00
parent 1c34bf7f50
commit b4395026c7
7 changed files with 1227 additions and 7 deletions

View File

@ -0,0 +1,442 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TravelAgencyDatabaseImplement;
#nullable disable
namespace TravelAgencyDatabaseImplement.Migrations
{
[DbContext(typeof(TravelAgencyDatabase))]
[Migration("20240429172546_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.18")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ExcursionDescription")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ExcursionName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Excursions");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ExcursionGroupName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("GuideId")
.HasColumnType("int");
b.Property<int>("ParticipantsAmount")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("GuideId");
b.HasIndex("UserId");
b.ToTable("ExcursionGroups");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ExcursionGroupId")
.HasColumnType("int");
b.Property<int>("TourId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ExcursionGroupId");
b.HasIndex("TourId");
b.ToTable("ExcursionGroupTours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionTour", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ExcursionId")
.HasColumnType("int");
b.Property<int>("TourId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ExcursionId");
b.HasIndex("TourId");
b.ToTable("ExcursionTours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Guide", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("GuideFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Guides");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ExcursionId")
.HasColumnType("int");
b.Property<string>("PlaceAddress")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PlaceName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ExcursionId");
b.ToTable("Places");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<double>("Price")
.HasColumnType("float");
b.Property<DateTime>("TourDate")
.HasColumnType("datetime2");
b.Property<string>("TourDescription")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("TourName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Tours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("GuideId")
.HasColumnType("int");
b.Property<DateTime>("TripDate")
.HasColumnType("datetime2");
b.Property<string>("TripName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("GuideId");
b.ToTable("Trips");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.TripPlace", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PlaceId")
.HasColumnType("int");
b.Property<int>("TripId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PlaceId");
b.HasIndex("TripId");
b.ToTable("TripPlaces");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide")
.WithMany()
.HasForeignKey("GuideId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Guide");
b.Navigation("User");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.ExcursionGroup", "ExcursionGroup")
.WithMany("Tours")
.HasForeignKey("ExcursionGroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TravelAgencyDatabaseImplement.Models.Tour", "Tour")
.WithMany("ExcursionGroups")
.HasForeignKey("TourId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ExcursionGroup");
b.Navigation("Tour");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionTour", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion")
.WithMany("Tours")
.HasForeignKey("ExcursionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TravelAgencyDatabaseImplement.Models.Tour", "Tour")
.WithMany("Excursions")
.HasForeignKey("TourId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Excursion");
b.Navigation("Tour");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion")
.WithMany()
.HasForeignKey("ExcursionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Excursion");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide")
.WithMany()
.HasForeignKey("GuideId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Guide");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.TripPlace", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Place", "Place")
.WithMany("Trips")
.HasForeignKey("PlaceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TravelAgencyDatabaseImplement.Models.Trip", "Trip")
.WithMany("Places")
.HasForeignKey("TripId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Place");
b.Navigation("Trip");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b =>
{
b.Navigation("Tours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b =>
{
b.Navigation("Tours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b =>
{
b.Navigation("Trips");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b =>
{
b.Navigation("ExcursionGroups");
b.Navigation("Excursions");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b =>
{
b.Navigation("Places");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,333 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace TravelAgencyDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Guides",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
GuideFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Guides", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Trips",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TripName = table.Column<string>(type: "nvarchar(max)", nullable: false),
TripDate = table.Column<DateTime>(type: "datetime2", nullable: false),
GuideId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Trips", x => x.Id);
table.ForeignKey(
name: "FK_Trips_Guides_GuideId",
column: x => x.GuideId,
principalTable: "Guides",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ExcursionGroups",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ExcursionGroupName = table.Column<string>(type: "nvarchar(max)", nullable: false),
ParticipantsAmount = table.Column<int>(type: "int", nullable: false),
UserId = table.Column<int>(type: "int", nullable: false),
GuideId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExcursionGroups", x => x.Id);
table.ForeignKey(
name: "FK_ExcursionGroups_Guides_GuideId",
column: x => x.GuideId,
principalTable: "Guides",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ExcursionGroups_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Excursions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ExcursionName = table.Column<string>(type: "nvarchar(max)", nullable: false),
ExcursionDescription = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Excursions", x => x.Id);
table.ForeignKey(
name: "FK_Excursions_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Tours",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TourName = table.Column<string>(type: "nvarchar(max)", nullable: false),
TourDescription = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false),
TourDate = table.Column<DateTime>(type: "datetime2", nullable: false),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Tours", x => x.Id);
table.ForeignKey(
name: "FK_Tours_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Places",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
PlaceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
PlaceAddress = table.Column<string>(type: "nvarchar(max)", nullable: false),
ExcursionId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Places", x => x.Id);
table.ForeignKey(
name: "FK_Places_Excursions_ExcursionId",
column: x => x.ExcursionId,
principalTable: "Excursions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ExcursionGroupTours",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ExcursionGroupId = table.Column<int>(type: "int", nullable: false),
TourId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExcursionGroupTours", x => x.Id);
table.ForeignKey(
name: "FK_ExcursionGroupTours_ExcursionGroups_ExcursionGroupId",
column: x => x.ExcursionGroupId,
principalTable: "ExcursionGroups",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ExcursionGroupTours_Tours_TourId",
column: x => x.TourId,
principalTable: "Tours",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ExcursionTours",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ExcursionId = table.Column<int>(type: "int", nullable: false),
TourId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ExcursionTours", x => x.Id);
table.ForeignKey(
name: "FK_ExcursionTours_Excursions_ExcursionId",
column: x => x.ExcursionId,
principalTable: "Excursions",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ExcursionTours_Tours_TourId",
column: x => x.TourId,
principalTable: "Tours",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "TripPlaces",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TripId = table.Column<int>(type: "int", nullable: false),
PlaceId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_TripPlaces", x => x.Id);
table.ForeignKey(
name: "FK_TripPlaces_Places_PlaceId",
column: x => x.PlaceId,
principalTable: "Places",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_TripPlaces_Trips_TripId",
column: x => x.TripId,
principalTable: "Trips",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ExcursionGroups_GuideId",
table: "ExcursionGroups",
column: "GuideId");
migrationBuilder.CreateIndex(
name: "IX_ExcursionGroups_UserId",
table: "ExcursionGroups",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_ExcursionGroupTours_ExcursionGroupId",
table: "ExcursionGroupTours",
column: "ExcursionGroupId");
migrationBuilder.CreateIndex(
name: "IX_ExcursionGroupTours_TourId",
table: "ExcursionGroupTours",
column: "TourId");
migrationBuilder.CreateIndex(
name: "IX_Excursions_UserId",
table: "Excursions",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_ExcursionTours_ExcursionId",
table: "ExcursionTours",
column: "ExcursionId");
migrationBuilder.CreateIndex(
name: "IX_ExcursionTours_TourId",
table: "ExcursionTours",
column: "TourId");
migrationBuilder.CreateIndex(
name: "IX_Places_ExcursionId",
table: "Places",
column: "ExcursionId");
migrationBuilder.CreateIndex(
name: "IX_Tours_UserId",
table: "Tours",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_TripPlaces_PlaceId",
table: "TripPlaces",
column: "PlaceId");
migrationBuilder.CreateIndex(
name: "IX_TripPlaces_TripId",
table: "TripPlaces",
column: "TripId");
migrationBuilder.CreateIndex(
name: "IX_Trips_GuideId",
table: "Trips",
column: "GuideId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ExcursionGroupTours");
migrationBuilder.DropTable(
name: "ExcursionTours");
migrationBuilder.DropTable(
name: "TripPlaces");
migrationBuilder.DropTable(
name: "ExcursionGroups");
migrationBuilder.DropTable(
name: "Tours");
migrationBuilder.DropTable(
name: "Places");
migrationBuilder.DropTable(
name: "Trips");
migrationBuilder.DropTable(
name: "Excursions");
migrationBuilder.DropTable(
name: "Guides");
migrationBuilder.DropTable(
name: "Users");
}
}
}

View File

@ -0,0 +1,439 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using TravelAgencyDatabaseImplement;
#nullable disable
namespace TravelAgencyDatabaseImplement.Migrations
{
[DbContext(typeof(TravelAgencyDatabase))]
partial class TravelAgencyDatabaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.18")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ExcursionDescription")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("ExcursionName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Excursions");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ExcursionGroupName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("GuideId")
.HasColumnType("int");
b.Property<int>("ParticipantsAmount")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("GuideId");
b.HasIndex("UserId");
b.ToTable("ExcursionGroups");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ExcursionGroupId")
.HasColumnType("int");
b.Property<int>("TourId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ExcursionGroupId");
b.HasIndex("TourId");
b.ToTable("ExcursionGroupTours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionTour", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ExcursionId")
.HasColumnType("int");
b.Property<int>("TourId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ExcursionId");
b.HasIndex("TourId");
b.ToTable("ExcursionTours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Guide", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("GuideFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Guides");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ExcursionId")
.HasColumnType("int");
b.Property<string>("PlaceAddress")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PlaceName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("ExcursionId");
b.ToTable("Places");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<double>("Price")
.HasColumnType("float");
b.Property<DateTime>("TourDate")
.HasColumnType("datetime2");
b.Property<string>("TourDescription")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("TourName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Tours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("GuideId")
.HasColumnType("int");
b.Property<DateTime>("TripDate")
.HasColumnType("datetime2");
b.Property<string>("TripName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("GuideId");
b.ToTable("Trips");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.TripPlace", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("PlaceId")
.HasColumnType("int");
b.Property<int>("TripId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("PlaceId");
b.HasIndex("TripId");
b.ToTable("TripPlaces");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("PhoneNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("UserFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide")
.WithMany()
.HasForeignKey("GuideId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Guide");
b.Navigation("User");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.ExcursionGroup", "ExcursionGroup")
.WithMany("Tours")
.HasForeignKey("ExcursionGroupId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TravelAgencyDatabaseImplement.Models.Tour", "Tour")
.WithMany("ExcursionGroups")
.HasForeignKey("TourId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ExcursionGroup");
b.Navigation("Tour");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionTour", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion")
.WithMany("Tours")
.HasForeignKey("ExcursionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TravelAgencyDatabaseImplement.Models.Tour", "Tour")
.WithMany("Excursions")
.HasForeignKey("TourId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Excursion");
b.Navigation("Tour");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion")
.WithMany()
.HasForeignKey("ExcursionId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Excursion");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide")
.WithMany()
.HasForeignKey("GuideId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Guide");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.TripPlace", b =>
{
b.HasOne("TravelAgencyDatabaseImplement.Models.Place", "Place")
.WithMany("Trips")
.HasForeignKey("PlaceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("TravelAgencyDatabaseImplement.Models.Trip", "Trip")
.WithMany("Places")
.HasForeignKey("TripId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Place");
b.Navigation("Trip");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b =>
{
b.Navigation("Tours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b =>
{
b.Navigation("Tours");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b =>
{
b.Navigation("Trips");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b =>
{
b.Navigation("ExcursionGroups");
b.Navigation("Excursions");
});
modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b =>
{
b.Navigation("Places");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations; using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.BindingModels;
using TravelAgencyContracts.ViewModels; using TravelAgencyContracts.ViewModels;
@ -21,6 +22,7 @@ namespace TravelAgencyDatabaseImplement.Models
[Required] [Required]
public int UserId { get; set; } public int UserId { get; set; }
[DeleteBehavior(DeleteBehavior.Restrict)]
public virtual User User { get; set; } public virtual User User { get; set; }
private Dictionary<int, ITourModel>? _excursionTours = null; private Dictionary<int, ITourModel>? _excursionTours = null;

View File

@ -3,6 +3,7 @@ using System.ComponentModel.DataAnnotations;
using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.BindingModels;
using TravelAgencyContracts.ViewModels; using TravelAgencyContracts.ViewModels;
using TravelAgencyDataModels.Models; using TravelAgencyDataModels.Models;
using Microsoft.EntityFrameworkCore;
namespace TravelAgencyDatabaseImplement.Models namespace TravelAgencyDatabaseImplement.Models
{ {
@ -19,13 +20,14 @@ namespace TravelAgencyDatabaseImplement.Models
[Required] [Required]
public int UserId { get; set; } public int UserId { get; set; }
[DeleteBehavior(DeleteBehavior.Restrict)]
public virtual User User { get; set; }
[Required] [Required]
public int GuideId { get; set; } public int GuideId { get; set; }
public virtual Guide Guide { get; set; } public virtual Guide Guide { get; set; }
public virtual User User { get; set; }
private Dictionary<int, ITourModel>? _excursionGroupTours = null; private Dictionary<int, ITourModel>? _excursionGroupTours = null;
[NotMapped] [NotMapped]

View File

@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations; using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.BindingModels;
using TravelAgencyContracts.ViewModels; using TravelAgencyContracts.ViewModels;
@ -24,6 +25,7 @@ namespace TravelAgencyDatabaseImplement.Models
[Required] [Required]
public int UserId { get; set; } public int UserId { get; set; }
[DeleteBehavior(DeleteBehavior.Restrict)]
public virtual User User { get; set; } public virtual User User { get; set; }
[ForeignKey("TourId")] [ForeignKey("TourId")]

View File

@ -7,9 +7,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.27" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.18" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.27" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.18" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.27"> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.18">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>