From d45d8bd6747f8f75f5426c0f961ac10576f37cad Mon Sep 17 00:00:00 2001 From: JohnMwaniki Date: Sun, 15 Feb 2026 23:32:47 +0300 Subject: [PATCH] chore: entity configs & relations migrations --- ...ties-Relations-And-validations.Designer.cs | 318 ++++++++++++++ ..._Add-Entities-Relations-And-validations.cs | 414 ++++++++++++++++++ .../Migrations/AppDbContextModelSnapshot.cs | 119 +++-- 3 files changed, 821 insertions(+), 30 deletions(-) create mode 100644 eventz-api/Eventz.Infrastructure/Migrations/20260211195350_Add-Entities-Relations-And-validations.Designer.cs create mode 100644 eventz-api/Eventz.Infrastructure/Migrations/20260211195350_Add-Entities-Relations-And-validations.cs diff --git a/eventz-api/Eventz.Infrastructure/Migrations/20260211195350_Add-Entities-Relations-And-validations.Designer.cs b/eventz-api/Eventz.Infrastructure/Migrations/20260211195350_Add-Entities-Relations-And-validations.Designer.cs new file mode 100644 index 0000000..b6d36d7 --- /dev/null +++ b/eventz-api/Eventz.Infrastructure/Migrations/20260211195350_Add-Entities-Relations-And-validations.Designer.cs @@ -0,0 +1,318 @@ +// +using System; +using Eventz.Infrastructure; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace Eventz.Infrastructure.Migrations +{ + [DbContext(typeof(AppDbContext))] + [Migration("20260211195350_Add-Entities-Relations-And-validations")] + partial class AddEntitiesRelationsAndvalidations + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Eventz.Domain.Entitites.Category", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CategoryToken") + .HasColumnType("uniqueidentifier"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Categories", (string)null); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.Event", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("CategoryId") + .HasColumnType("int"); + + b.Property("Description") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("EventToken") + .HasColumnType("uniqueidentifier"); + + b.Property("IsPublic") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("Name") + .IsRequired() + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("VenueId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CategoryId"); + + b.HasIndex("VenueId"); + + b.ToTable("Events", (string)null); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.EventRegistration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CheckedIn") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); + + b.Property("EventId") + .HasColumnType("int"); + + b.Property("EventRegistrationToken") + .HasColumnType("uniqueidentifier"); + + b.Property("RegisteredAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETUTCDATE()"); + + b.Property("UserId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EventId"); + + b.HasIndex("UserId", "EventId") + .IsUnique(); + + b.ToTable("EventRegistration"); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.Ticket", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("EventId") + .HasColumnType("int"); + + b.Property("Price") + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)"); + + b.Property("Quantity") + .HasColumnType("int"); + + b.Property("TicketToken") + .HasColumnType("uniqueidentifier"); + + b.Property("Type") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("EventId"); + + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETUTCDATE()"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserToken") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("Email") + .IsUnique(); + + b.ToTable("Users", (string)null); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.Venue", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Capacity") + .HasColumnType("int"); + + b.Property("City") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("VenueToken") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("Id"); + + b.ToTable("Venues", (string)null); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.Event", b => + { + b.HasOne("Eventz.Domain.Entitites.Category", "Category") + .WithMany("Events") + .HasForeignKey("CategoryId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Eventz.Domain.Entitites.Venue", "Venue") + .WithMany("Events") + .HasForeignKey("VenueId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.Navigation("Category"); + + b.Navigation("Venue"); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.EventRegistration", b => + { + b.HasOne("Eventz.Domain.Entitites.Event", "Event") + .WithMany("Registrations") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Eventz.Domain.Entitites.User", "User") + .WithMany("EventRegistrations") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.Ticket", b => + { + b.HasOne("Eventz.Domain.Entitites.Event", "Event") + .WithMany("Tickets") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Event"); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.Category", b => + { + b.Navigation("Events"); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.Event", b => + { + b.Navigation("Registrations"); + + b.Navigation("Tickets"); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.User", b => + { + b.Navigation("EventRegistrations"); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.Venue", b => + { + b.Navigation("Events"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/eventz-api/Eventz.Infrastructure/Migrations/20260211195350_Add-Entities-Relations-And-validations.cs b/eventz-api/Eventz.Infrastructure/Migrations/20260211195350_Add-Entities-Relations-And-validations.cs new file mode 100644 index 0000000..4ab9144 --- /dev/null +++ b/eventz-api/Eventz.Infrastructure/Migrations/20260211195350_Add-Entities-Relations-And-validations.cs @@ -0,0 +1,414 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace Eventz.Infrastructure.Migrations +{ + /// + public partial class AddEntitiesRelationsAndvalidations : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_EventRegistration_Events_EventId1", + table: "EventRegistration"); + + migrationBuilder.DropForeignKey( + name: "FK_Events_Categories_CategoryId", + table: "Events"); + + migrationBuilder.DropForeignKey( + name: "FK_Events_Venue_VenueId", + table: "Events"); + + migrationBuilder.DropForeignKey( + name: "FK_Ticket_Events_EventId", + table: "Ticket"); + + migrationBuilder.DropIndex( + name: "IX_EventRegistration_EventId1", + table: "EventRegistration"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Venue", + table: "Venue"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Ticket", + table: "Ticket"); + + migrationBuilder.DropColumn( + name: "OrganizerId", + table: "Events"); + + migrationBuilder.DropColumn( + name: "EventId1", + table: "EventRegistration"); + + migrationBuilder.RenameTable( + name: "Venue", + newName: "Venues"); + + migrationBuilder.RenameTable( + name: "Ticket", + newName: "Tickets"); + + migrationBuilder.RenameIndex( + name: "IX_Ticket_EventId", + table: "Tickets", + newName: "IX_Tickets_EventId"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Events", + type: "nvarchar(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "IsPublic", + table: "Events", + type: "bit", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "bit"); + + migrationBuilder.AlterColumn( + name: "Description", + table: "Events", + type: "nvarchar(256)", + maxLength: 256, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "EventRegistration", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "RegisteredAt", + table: "EventRegistration", + type: "datetime2", + nullable: false, + defaultValueSql: "GETUTCDATE()", + oldClrType: typeof(DateTime), + oldType: "datetime2"); + + migrationBuilder.AlterColumn( + name: "EventId", + table: "EventRegistration", + type: "int", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AlterColumn( + name: "CheckedIn", + table: "EventRegistration", + type: "bit", + nullable: false, + defaultValue: false, + oldClrType: typeof(bool), + oldType: "bit"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Categories", + type: "nvarchar(100)", + maxLength: 100, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Venues", + table: "Venues", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Tickets", + table: "Tickets", + column: "Id"); + + migrationBuilder.CreateTable( + name: "Users", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + UserToken = table.Column(type: "uniqueidentifier", nullable: false), + UserName = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + Email = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + Password = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: false), + CreatedAt = table.Column(type: "datetime2", nullable: false, defaultValueSql: "GETUTCDATE()") + }, + constraints: table => + { + table.PrimaryKey("PK_Users", x => x.Id); + }); + + migrationBuilder.CreateIndex( + name: "IX_EventRegistration_EventId", + table: "EventRegistration", + column: "EventId"); + + migrationBuilder.CreateIndex( + name: "IX_EventRegistration_UserId_EventId", + table: "EventRegistration", + columns: new[] { "UserId", "EventId" }, + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_Venues_Id", + table: "Venues", + column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_Users_Email", + table: "Users", + column: "Email", + unique: true); + + migrationBuilder.AddForeignKey( + name: "FK_EventRegistration_Events_EventId", + table: "EventRegistration", + column: "EventId", + principalTable: "Events", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_EventRegistration_Users_UserId", + table: "EventRegistration", + column: "UserId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Events_Categories_CategoryId", + table: "Events", + column: "CategoryId", + principalTable: "Categories", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Events_Venues_VenueId", + table: "Events", + column: "VenueId", + principalTable: "Venues", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_Tickets_Events_EventId", + table: "Tickets", + column: "EventId", + principalTable: "Events", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_EventRegistration_Events_EventId", + table: "EventRegistration"); + + migrationBuilder.DropForeignKey( + name: "FK_EventRegistration_Users_UserId", + table: "EventRegistration"); + + migrationBuilder.DropForeignKey( + name: "FK_Events_Categories_CategoryId", + table: "Events"); + + migrationBuilder.DropForeignKey( + name: "FK_Events_Venues_VenueId", + table: "Events"); + + migrationBuilder.DropForeignKey( + name: "FK_Tickets_Events_EventId", + table: "Tickets"); + + migrationBuilder.DropTable( + name: "Users"); + + migrationBuilder.DropIndex( + name: "IX_EventRegistration_EventId", + table: "EventRegistration"); + + migrationBuilder.DropIndex( + name: "IX_EventRegistration_UserId_EventId", + table: "EventRegistration"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Venues", + table: "Venues"); + + migrationBuilder.DropIndex( + name: "IX_Venues_Id", + table: "Venues"); + + migrationBuilder.DropPrimaryKey( + name: "PK_Tickets", + table: "Tickets"); + + migrationBuilder.RenameTable( + name: "Venues", + newName: "Venue"); + + migrationBuilder.RenameTable( + name: "Tickets", + newName: "Ticket"); + + migrationBuilder.RenameIndex( + name: "IX_Tickets_EventId", + table: "Ticket", + newName: "IX_Ticket_EventId"); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Events", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(256)", + oldMaxLength: 256); + + migrationBuilder.AlterColumn( + name: "IsPublic", + table: "Events", + type: "bit", + nullable: false, + oldClrType: typeof(bool), + oldType: "bit", + oldDefaultValue: false); + + migrationBuilder.AlterColumn( + name: "Description", + table: "Events", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(256)", + oldMaxLength: 256); + + migrationBuilder.AddColumn( + name: "OrganizerId", + table: "Events", + type: "nvarchar(max)", + nullable: false, + defaultValue: ""); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "EventRegistration", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "RegisteredAt", + table: "EventRegistration", + type: "datetime2", + nullable: false, + oldClrType: typeof(DateTime), + oldType: "datetime2", + oldDefaultValueSql: "GETUTCDATE()"); + + migrationBuilder.AlterColumn( + name: "EventId", + table: "EventRegistration", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(int), + oldType: "int"); + + migrationBuilder.AlterColumn( + name: "CheckedIn", + table: "EventRegistration", + type: "bit", + nullable: false, + oldClrType: typeof(bool), + oldType: "bit", + oldDefaultValue: false); + + migrationBuilder.AddColumn( + name: "EventId1", + table: "EventRegistration", + type: "int", + nullable: false, + defaultValue: 0); + + migrationBuilder.AlterColumn( + name: "Name", + table: "Categories", + type: "nvarchar(max)", + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(100)", + oldMaxLength: 100); + + migrationBuilder.AddPrimaryKey( + name: "PK_Venue", + table: "Venue", + column: "Id"); + + migrationBuilder.AddPrimaryKey( + name: "PK_Ticket", + table: "Ticket", + column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_EventRegistration_EventId1", + table: "EventRegistration", + column: "EventId1"); + + migrationBuilder.AddForeignKey( + name: "FK_EventRegistration_Events_EventId1", + table: "EventRegistration", + column: "EventId1", + principalTable: "Events", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Events_Categories_CategoryId", + table: "Events", + column: "CategoryId", + principalTable: "Categories", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Events_Venue_VenueId", + table: "Events", + column: "VenueId", + principalTable: "Venue", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Ticket_Events_EventId", + table: "Ticket", + column: "EventId", + principalTable: "Events", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/eventz-api/Eventz.Infrastructure/Migrations/AppDbContextModelSnapshot.cs b/eventz-api/Eventz.Infrastructure/Migrations/AppDbContextModelSnapshot.cs index 35e9a34..71133d6 100644 --- a/eventz-api/Eventz.Infrastructure/Migrations/AppDbContextModelSnapshot.cs +++ b/eventz-api/Eventz.Infrastructure/Migrations/AppDbContextModelSnapshot.cs @@ -35,15 +35,17 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Description") .IsRequired() + .HasMaxLength(10000) .HasColumnType("nvarchar(max)"); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); b.HasKey("Id"); - b.ToTable("Categories"); + b.ToTable("Categories", (string)null); }); modelBuilder.Entity("Eventz.Domain.Entitites.Event", b => @@ -62,7 +64,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Property("Description") .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("EndDate") .HasColumnType("datetime2"); @@ -71,15 +74,14 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("uniqueidentifier"); b.Property("IsPublic") - .HasColumnType("bit"); + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); b.Property("Name") .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("OrganizerId") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .HasMaxLength(256) + .HasColumnType("nvarchar(256)"); b.Property("StartDate") .HasColumnType("datetime2"); @@ -93,7 +95,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("VenueId"); - b.ToTable("Events"); + b.ToTable("Events", (string)null); }); modelBuilder.Entity("Eventz.Domain.Entitites.EventRegistration", b => @@ -105,28 +107,30 @@ protected override void BuildModel(ModelBuilder modelBuilder) SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("CheckedIn") - .HasColumnType("bit"); - - b.Property("EventId") - .IsRequired() - .HasColumnType("nvarchar(max)"); + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false); - b.Property("EventId1") + b.Property("EventId") .HasColumnType("int"); b.Property("EventRegistrationToken") .HasColumnType("uniqueidentifier"); b.Property("RegisteredAt") - .HasColumnType("datetime2"); + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETUTCDATE()"); - b.Property("UserId") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("UserId") + .HasColumnType("int"); b.HasKey("Id"); - b.HasIndex("EventId1"); + b.HasIndex("EventId"); + + b.HasIndex("UserId", "EventId") + .IsUnique(); b.ToTable("EventRegistration"); }); @@ -143,6 +147,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) .HasColumnType("int"); b.Property("Price") + .HasPrecision(18, 2) .HasColumnType("decimal(18,2)"); b.Property("Quantity") @@ -159,7 +164,46 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasIndex("EventId"); - b.ToTable("Ticket"); + b.ToTable("Tickets", (string)null); + }); + + modelBuilder.Entity("Eventz.Domain.Entitites.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CreatedAt") + .ValueGeneratedOnAdd() + .HasColumnType("datetime2") + .HasDefaultValueSql("GETUTCDATE()"); + + b.Property("Email") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("Password") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserName") + .IsRequired() + .HasMaxLength(255) + .HasColumnType("nvarchar(255)"); + + b.Property("UserToken") + .HasColumnType("uniqueidentifier"); + + b.HasKey("Id"); + + b.HasIndex("Email") + .IsUnique(); + + b.ToTable("Users", (string)null); }); modelBuilder.Entity("Eventz.Domain.Entitites.Venue", b => @@ -190,37 +234,47 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey("Id"); - b.ToTable("Venue"); + b.HasIndex("Id"); + + b.ToTable("Venues", (string)null); }); modelBuilder.Entity("Eventz.Domain.Entitites.Event", b => { - b.HasOne("Eventz.Domain.Entitites.Category", "category") + b.HasOne("Eventz.Domain.Entitites.Category", "Category") .WithMany("Events") .HasForeignKey("CategoryId") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.HasOne("Eventz.Domain.Entitites.Venue", "venue") + b.HasOne("Eventz.Domain.Entitites.Venue", "Venue") .WithMany("Events") .HasForeignKey("VenueId") - .OnDelete(DeleteBehavior.Cascade) + .OnDelete(DeleteBehavior.Restrict) .IsRequired(); - b.Navigation("category"); + b.Navigation("Category"); - b.Navigation("venue"); + b.Navigation("Venue"); }); modelBuilder.Entity("Eventz.Domain.Entitites.EventRegistration", b => { b.HasOne("Eventz.Domain.Entitites.Event", "Event") .WithMany("Registrations") - .HasForeignKey("EventId1") + .HasForeignKey("EventId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Eventz.Domain.Entitites.User", "User") + .WithMany("EventRegistrations") + .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Event"); + + b.Navigation("User"); }); modelBuilder.Entity("Eventz.Domain.Entitites.Ticket", b => @@ -246,6 +300,11 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.Navigation("Tickets"); }); + modelBuilder.Entity("Eventz.Domain.Entitites.User", b => + { + b.Navigation("EventRegistrations"); + }); + modelBuilder.Entity("Eventz.Domain.Entitites.Venue", b => { b.Navigation("Events");