Создание бд

This commit is contained in:
AnnZhimol 2023-04-06 01:23:11 +04:00
parent dd85562428
commit f63a05d7d4
5 changed files with 1565 additions and 0 deletions

View File

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

View File

@ -0,0 +1,569 @@
// <auto-generated />
using System;
using HotelDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace HotelDataBaseImplement.Migrations
{
[DbContext(typeof(HotelDataBase))]
[Migration("20230405210621_InitialCreate")]
partial class InitialCreate
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ConferenceName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("OrganiserId")
.HasColumnType("int");
b.Property<DateTime>("StartDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("OrganiserId");
b.ToTable("Conferences");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ConferenceId")
.HasColumnType("int");
b.Property<int>("HeadwaiterId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ConferenceId");
b.HasIndex("HeadwaiterId");
b.ToTable("ConferenceBookings");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ConferenceBookingId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("DinnerId")
.HasColumnType("int");
b.Property<int>("DinnercId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ConferenceBookingId");
b.HasIndex("DinnercId");
b.ToTable("ConferenceBookingDinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ConferenceId")
.HasColumnType("int");
b.Property<int>("MemberId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ConferenceId");
b.HasIndex("MemberId");
b.ToTable("ConferenceMembers");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("DinnerName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("DinnetPrice")
.HasColumnType("float");
b.Property<int>("HeadwaiterId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("HeadwaiterId");
b.ToTable("Dinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("HeadwaiterEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HeadwaiterFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HeadwaiterLogin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HeadwaiterNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HeadwaiterPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Headwaiters");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("MealPlanName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("MealPlanPrice")
.HasColumnType("float");
b.Property<int>("OrganiserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrganiserId");
b.ToTable("MealPlans");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MealPlanId")
.HasColumnType("int");
b.Property<int>("MemberId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MealPlanId");
b.HasIndex("MemberId");
b.ToTable("MealPlanMembers");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Citizenship")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MemberFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("OrganiserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrganiserId");
b.ToTable("Members");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("OrganiserEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganiserFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganiserLogin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganiserNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganiserPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Organisers");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("HeadwaiterId")
.HasColumnType("int");
b.Property<int>("MealPlanId")
.HasColumnType("int");
b.Property<string>("RoomFrame")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("RoomName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("RoomPrice")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("HeadwaiterId");
b.HasIndex("MealPlanId");
b.ToTable("Rooms");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("DinnerId")
.HasColumnType("int");
b.Property<int>("RoomId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DinnerId");
b.HasIndex("RoomId");
b.ToTable("RoomDinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
.WithMany("Conferences")
.HasForeignKey("OrganiserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organiser");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
.WithMany("ConferenceBookings")
.HasForeignKey("ConferenceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
.WithMany("ConferenceBookings")
.HasForeignKey("HeadwaiterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Conference");
b.Navigation("Headwaiter");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
{
b.HasOne("HotelDataBaseImplement.Models.ConferenceBooking", "ConferenceBooking")
.WithMany("Dinners")
.HasForeignKey("ConferenceBookingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
.WithMany("ConferenceBookingDinners")
.HasForeignKey("DinnercId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ConferenceBooking");
b.Navigation("Dinner");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
.WithMany("Members")
.HasForeignKey("ConferenceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
.WithMany("ConferenceMember")
.HasForeignKey("MemberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Conference");
b.Navigation("Member");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiters")
.WithMany("Dinners")
.HasForeignKey("HeadwaiterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Headwaiters");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
.WithMany("MealPlans")
.HasForeignKey("OrganiserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organiser");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
{
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
.WithMany("Members")
.HasForeignKey("MealPlanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
.WithMany("MealPlanMember")
.HasForeignKey("MemberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MealPlan");
b.Navigation("Member");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
.WithMany("Members")
.HasForeignKey("OrganiserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organiser");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
.WithMany("Rooms")
.HasForeignKey("HeadwaiterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
.WithMany("Rooms")
.HasForeignKey("MealPlanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Headwaiter");
b.Navigation("MealPlan");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
.WithMany("RoomDinners")
.HasForeignKey("DinnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Room", "Room")
.WithMany("Dinners")
.HasForeignKey("RoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Dinner");
b.Navigation("Room");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
{
b.Navigation("ConferenceBookings");
b.Navigation("Members");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
{
b.Navigation("Dinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
{
b.Navigation("ConferenceBookingDinners");
b.Navigation("RoomDinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
{
b.Navigation("ConferenceBookings");
b.Navigation("Dinners");
b.Navigation("Rooms");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
{
b.Navigation("Members");
b.Navigation("Rooms");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
{
b.Navigation("ConferenceMember");
b.Navigation("MealPlanMember");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
{
b.Navigation("Conferences");
b.Navigation("MealPlans");
b.Navigation("Members");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
{
b.Navigation("Dinners");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,415 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace HotelDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Headwaiters",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
HeadwaiterFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
HeadwaiterEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
HeadwaiterPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
HeadwaiterLogin = table.Column<string>(type: "nvarchar(max)", nullable: false),
HeadwaiterNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Headwaiters", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Organisers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
OrganiserFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserPassword = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserLogin = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserEmail = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Organisers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Dinners",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
HeadwaiterId = table.Column<int>(type: "int", nullable: false),
DinnerName = table.Column<string>(type: "nvarchar(max)", nullable: false),
DinnetPrice = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Dinners", x => x.Id);
table.ForeignKey(
name: "FK_Dinners_Headwaiters_HeadwaiterId",
column: x => x.HeadwaiterId,
principalTable: "Headwaiters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Conferences",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ConferenceName = table.Column<string>(type: "nvarchar(max)", nullable: false),
StartDate = table.Column<DateTime>(type: "datetime2", nullable: false),
OrganiserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Conferences", x => x.Id);
table.ForeignKey(
name: "FK_Conferences_Organisers_OrganiserId",
column: x => x.OrganiserId,
principalTable: "Organisers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "MealPlans",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
MealPlanName = table.Column<string>(type: "nvarchar(max)", nullable: false),
MealPlanPrice = table.Column<double>(type: "float", nullable: false),
OrganiserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MealPlans", x => x.Id);
table.ForeignKey(
name: "FK_MealPlans_Organisers_OrganiserId",
column: x => x.OrganiserId,
principalTable: "Organisers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Members",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
MemberFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Citizenship = table.Column<string>(type: "nvarchar(max)", nullable: false),
OrganiserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Members", x => x.Id);
table.ForeignKey(
name: "FK_Members_Organisers_OrganiserId",
column: x => x.OrganiserId,
principalTable: "Organisers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ConferenceBookings",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
HeadwaiterId = table.Column<int>(type: "int", nullable: false),
ConferenceId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ConferenceBookings", x => x.Id);
table.ForeignKey(
name: "FK_ConferenceBookings_Conferences_ConferenceId",
column: x => x.ConferenceId,
principalTable: "Conferences",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ConferenceBookings_Headwaiters_HeadwaiterId",
column: x => x.HeadwaiterId,
principalTable: "Headwaiters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Rooms",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RoomName = table.Column<string>(type: "nvarchar(max)", nullable: false),
RoomFrame = table.Column<string>(type: "nvarchar(max)", nullable: false),
RoomPrice = table.Column<double>(type: "float", nullable: false),
HeadwaiterId = table.Column<int>(type: "int", nullable: false),
MealPlanId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Rooms", x => x.Id);
table.ForeignKey(
name: "FK_Rooms_Headwaiters_HeadwaiterId",
column: x => x.HeadwaiterId,
principalTable: "Headwaiters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Rooms_MealPlans_MealPlanId",
column: x => x.MealPlanId,
principalTable: "MealPlans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ConferenceMembers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
MemberId = table.Column<int>(type: "int", nullable: false),
ConferenceId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ConferenceMembers", x => x.Id);
table.ForeignKey(
name: "FK_ConferenceMembers_Conferences_ConferenceId",
column: x => x.ConferenceId,
principalTable: "Conferences",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ConferenceMembers_Members_MemberId",
column: x => x.MemberId,
principalTable: "Members",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "MealPlanMembers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
MemberId = table.Column<int>(type: "int", nullable: false),
MealPlanId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_MealPlanMembers", x => x.Id);
table.ForeignKey(
name: "FK_MealPlanMembers_MealPlans_MealPlanId",
column: x => x.MealPlanId,
principalTable: "MealPlans",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_MealPlanMembers_Members_MemberId",
column: x => x.MemberId,
principalTable: "Members",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "ConferenceBookingDinners",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ConferenceBookingId = table.Column<int>(type: "int", nullable: false),
DinnerId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
DinnercId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ConferenceBookingDinners", x => x.Id);
table.ForeignKey(
name: "FK_ConferenceBookingDinners_ConferenceBookings_ConferenceBookingId",
column: x => x.ConferenceBookingId,
principalTable: "ConferenceBookings",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_ConferenceBookingDinners_Dinners_DinnercId",
column: x => x.DinnercId,
principalTable: "Dinners",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "RoomDinners",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
RoomId = table.Column<int>(type: "int", nullable: false),
DinnerId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_RoomDinners", x => x.Id);
table.ForeignKey(
name: "FK_RoomDinners_Dinners_DinnerId",
column: x => x.DinnerId,
principalTable: "Dinners",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_RoomDinners_Rooms_RoomId",
column: x => x.RoomId,
principalTable: "Rooms",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateIndex(
name: "IX_ConferenceBookingDinners_ConferenceBookingId",
table: "ConferenceBookingDinners",
column: "ConferenceBookingId");
migrationBuilder.CreateIndex(
name: "IX_ConferenceBookingDinners_DinnercId",
table: "ConferenceBookingDinners",
column: "DinnercId");
migrationBuilder.CreateIndex(
name: "IX_ConferenceBookings_ConferenceId",
table: "ConferenceBookings",
column: "ConferenceId");
migrationBuilder.CreateIndex(
name: "IX_ConferenceBookings_HeadwaiterId",
table: "ConferenceBookings",
column: "HeadwaiterId");
migrationBuilder.CreateIndex(
name: "IX_ConferenceMembers_ConferenceId",
table: "ConferenceMembers",
column: "ConferenceId");
migrationBuilder.CreateIndex(
name: "IX_ConferenceMembers_MemberId",
table: "ConferenceMembers",
column: "MemberId");
migrationBuilder.CreateIndex(
name: "IX_Conferences_OrganiserId",
table: "Conferences",
column: "OrganiserId");
migrationBuilder.CreateIndex(
name: "IX_Dinners_HeadwaiterId",
table: "Dinners",
column: "HeadwaiterId");
migrationBuilder.CreateIndex(
name: "IX_MealPlanMembers_MealPlanId",
table: "MealPlanMembers",
column: "MealPlanId");
migrationBuilder.CreateIndex(
name: "IX_MealPlanMembers_MemberId",
table: "MealPlanMembers",
column: "MemberId");
migrationBuilder.CreateIndex(
name: "IX_MealPlans_OrganiserId",
table: "MealPlans",
column: "OrganiserId");
migrationBuilder.CreateIndex(
name: "IX_Members_OrganiserId",
table: "Members",
column: "OrganiserId");
migrationBuilder.CreateIndex(
name: "IX_RoomDinners_DinnerId",
table: "RoomDinners",
column: "DinnerId");
migrationBuilder.CreateIndex(
name: "IX_RoomDinners_RoomId",
table: "RoomDinners",
column: "RoomId");
migrationBuilder.CreateIndex(
name: "IX_Rooms_HeadwaiterId",
table: "Rooms",
column: "HeadwaiterId");
migrationBuilder.CreateIndex(
name: "IX_Rooms_MealPlanId",
table: "Rooms",
column: "MealPlanId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ConferenceBookingDinners");
migrationBuilder.DropTable(
name: "ConferenceMembers");
migrationBuilder.DropTable(
name: "MealPlanMembers");
migrationBuilder.DropTable(
name: "RoomDinners");
migrationBuilder.DropTable(
name: "ConferenceBookings");
migrationBuilder.DropTable(
name: "Members");
migrationBuilder.DropTable(
name: "Dinners");
migrationBuilder.DropTable(
name: "Rooms");
migrationBuilder.DropTable(
name: "Conferences");
migrationBuilder.DropTable(
name: "Headwaiters");
migrationBuilder.DropTable(
name: "MealPlans");
migrationBuilder.DropTable(
name: "Organisers");
}
}
}

View File

@ -0,0 +1,566 @@
// <auto-generated />
using System;
using HotelDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace HotelDataBaseImplement.Migrations
{
[DbContext(typeof(HotelDataBase))]
partial class HotelDataBaseModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.4")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ConferenceName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("OrganiserId")
.HasColumnType("int");
b.Property<DateTime>("StartDate")
.HasColumnType("datetime2");
b.HasKey("Id");
b.HasIndex("OrganiserId");
b.ToTable("Conferences");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ConferenceId")
.HasColumnType("int");
b.Property<int>("HeadwaiterId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ConferenceId");
b.HasIndex("HeadwaiterId");
b.ToTable("ConferenceBookings");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ConferenceBookingId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("DinnerId")
.HasColumnType("int");
b.Property<int>("DinnercId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ConferenceBookingId");
b.HasIndex("DinnercId");
b.ToTable("ConferenceBookingDinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ConferenceId")
.HasColumnType("int");
b.Property<int>("MemberId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ConferenceId");
b.HasIndex("MemberId");
b.ToTable("ConferenceMembers");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("DinnerName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("DinnetPrice")
.HasColumnType("float");
b.Property<int>("HeadwaiterId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("HeadwaiterId");
b.ToTable("Dinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("HeadwaiterEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HeadwaiterFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HeadwaiterLogin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HeadwaiterNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("HeadwaiterPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Headwaiters");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("MealPlanName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("MealPlanPrice")
.HasColumnType("float");
b.Property<int>("OrganiserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrganiserId");
b.ToTable("MealPlans");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("MealPlanId")
.HasColumnType("int");
b.Property<int>("MemberId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MealPlanId");
b.HasIndex("MemberId");
b.ToTable("MealPlanMembers");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Citizenship")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("MemberFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("OrganiserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("OrganiserId");
b.ToTable("Members");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("OrganiserEmail")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganiserFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganiserLogin")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganiserNumber")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("OrganiserPassword")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Organisers");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("HeadwaiterId")
.HasColumnType("int");
b.Property<int>("MealPlanId")
.HasColumnType("int");
b.Property<string>("RoomFrame")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("RoomName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("RoomPrice")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("HeadwaiterId");
b.HasIndex("MealPlanId");
b.ToTable("Rooms");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("DinnerId")
.HasColumnType("int");
b.Property<int>("RoomId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DinnerId");
b.HasIndex("RoomId");
b.ToTable("RoomDinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
.WithMany("Conferences")
.HasForeignKey("OrganiserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organiser");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
.WithMany("ConferenceBookings")
.HasForeignKey("ConferenceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
.WithMany("ConferenceBookings")
.HasForeignKey("HeadwaiterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Conference");
b.Navigation("Headwaiter");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBookingDinner", b =>
{
b.HasOne("HotelDataBaseImplement.Models.ConferenceBooking", "ConferenceBooking")
.WithMany("Dinners")
.HasForeignKey("ConferenceBookingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
.WithMany("ConferenceBookingDinners")
.HasForeignKey("DinnercId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("ConferenceBooking");
b.Navigation("Dinner");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceMember", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Conference", "Conference")
.WithMany("Members")
.HasForeignKey("ConferenceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
.WithMany("ConferenceMember")
.HasForeignKey("MemberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Conference");
b.Navigation("Member");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiters")
.WithMany("Dinners")
.HasForeignKey("HeadwaiterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Headwaiters");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
.WithMany("MealPlans")
.HasForeignKey("OrganiserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organiser");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlanMember", b =>
{
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
.WithMany("Members")
.HasForeignKey("MealPlanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Member", "Member")
.WithMany("MealPlanMember")
.HasForeignKey("MemberId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("MealPlan");
b.Navigation("Member");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Organiser", "Organiser")
.WithMany("Members")
.HasForeignKey("OrganiserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Organiser");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Headwaiter", "Headwaiter")
.WithMany("Rooms")
.HasForeignKey("HeadwaiterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.MealPlan", "MealPlan")
.WithMany("Rooms")
.HasForeignKey("MealPlanId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Headwaiter");
b.Navigation("MealPlan");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.RoomDinner", b =>
{
b.HasOne("HotelDataBaseImplement.Models.Dinner", "Dinner")
.WithMany("RoomDinners")
.HasForeignKey("DinnerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("HotelDataBaseImplement.Models.Room", "Room")
.WithMany("Dinners")
.HasForeignKey("RoomId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Dinner");
b.Navigation("Room");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Conference", b =>
{
b.Navigation("ConferenceBookings");
b.Navigation("Members");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.ConferenceBooking", b =>
{
b.Navigation("Dinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Dinner", b =>
{
b.Navigation("ConferenceBookingDinners");
b.Navigation("RoomDinners");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Headwaiter", b =>
{
b.Navigation("ConferenceBookings");
b.Navigation("Dinners");
b.Navigation("Rooms");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.MealPlan", b =>
{
b.Navigation("Members");
b.Navigation("Rooms");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Member", b =>
{
b.Navigation("ConferenceMember");
b.Navigation("MealPlanMember");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Organiser", b =>
{
b.Navigation("Conferences");
b.Navigation("MealPlans");
b.Navigation("Members");
});
modelBuilder.Entity("HotelDataBaseImplement.Models.Room", b =>
{
b.Navigation("Dinners");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -8,4 +8,15 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\HotelDataBaseImplement\HotelDataBaseImplement.csproj" />
</ItemGroup>
</Project>