From ee43dc60d86b1d1b1dcd8659751b4856fbba78ab Mon Sep 17 00:00:00 2001 From: Francesco Lorenzo D'Amico Date: Tue, 18 Aug 2026 16:46:57 +0200 Subject: [PATCH] Create EF-Migration for NotificationSent-field --- ...tificationSentToContactMessage.Designer.cs | 128 ++++++++++++++++++ ...749_AddNotificationSentToContactMessage.cs | 49 +++++++ .../RazorPagesMovieContextModelSnapshot.cs | 7 +- 3 files changed, 182 insertions(+), 2 deletions(-) create mode 100644 RazorPagesMovie/Migrations/20260818134749_AddNotificationSentToContactMessage.Designer.cs create mode 100644 RazorPagesMovie/Migrations/20260818134749_AddNotificationSentToContactMessage.cs diff --git a/RazorPagesMovie/Migrations/20260818134749_AddNotificationSentToContactMessage.Designer.cs b/RazorPagesMovie/Migrations/20260818134749_AddNotificationSentToContactMessage.Designer.cs new file mode 100644 index 0000000..9adce1a --- /dev/null +++ b/RazorPagesMovie/Migrations/20260818134749_AddNotificationSentToContactMessage.Designer.cs @@ -0,0 +1,128 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using RazorPagesMovie.Data; + +#nullable disable + +namespace RazorPagesMovie.Migrations +{ + [DbContext(typeof(RazorPagesMovieContext))] + [Migration("20260818134749_AddNotificationSentToContactMessage")] + partial class AddNotificationSentToContactMessage + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.28") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("RazorPagesMovie.Models.AdminUser", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("PasswordHash") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Username") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("AdminUser"); + }); + + modelBuilder.Entity("RazorPagesMovie.Models.ContactMessage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasMaxLength(200) + .HasColumnType("nvarchar(200)"); + + b.Property("Message") + .IsRequired() + .HasMaxLength(5000) + .HasColumnType("nvarchar(max)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("NotificationSent") + .HasColumnType("bit"); + + b.Property("Phone") + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("SentAt") + .HasColumnType("datetime2"); + + b.Property("Subject") + .HasMaxLength(150) + .HasColumnType("nvarchar(150)"); + + b.HasKey("Id"); + + b.ToTable("ContactMessage"); + }); + + modelBuilder.Entity("RazorPagesMovie.Models.Movie", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Genre") + .IsRequired() + .HasMaxLength(30) + .HasColumnType("nvarchar(30)"); + + b.Property("Price") + .HasColumnType("decimal(18, 2)"); + + b.Property("Rating") + .IsRequired() + .HasMaxLength(5) + .HasColumnType("nvarchar(5)"); + + b.Property("ReleaseDate") + .HasColumnType("datetime2"); + + b.Property("Title") + .IsRequired() + .HasMaxLength(60) + .HasColumnType("nvarchar(60)"); + + b.HasKey("Id"); + + b.ToTable("Movie"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/RazorPagesMovie/Migrations/20260818134749_AddNotificationSentToContactMessage.cs b/RazorPagesMovie/Migrations/20260818134749_AddNotificationSentToContactMessage.cs new file mode 100644 index 0000000..d8d434d --- /dev/null +++ b/RazorPagesMovie/Migrations/20260818134749_AddNotificationSentToContactMessage.cs @@ -0,0 +1,49 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace RazorPagesMovie.Migrations +{ + /// + public partial class AddNotificationSentToContactMessage : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.AlterColumn( + name: "Message", + table: "ContactMessage", + type: "nvarchar(max)", + maxLength: 5000, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(4000)", + oldMaxLength: 4000); + + migrationBuilder.AddColumn( + name: "NotificationSent", + table: "ContactMessage", + type: "bit", + nullable: false, + defaultValue: false); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropColumn( + name: "NotificationSent", + table: "ContactMessage"); + + migrationBuilder.AlterColumn( + name: "Message", + table: "ContactMessage", + type: "nvarchar(4000)", + maxLength: 4000, + nullable: false, + oldClrType: typeof(string), + oldType: "nvarchar(max)", + oldMaxLength: 5000); + } + } +} diff --git a/RazorPagesMovie/Migrations/RazorPagesMovieContextModelSnapshot.cs b/RazorPagesMovie/Migrations/RazorPagesMovieContextModelSnapshot.cs index a601172..c633a99 100644 --- a/RazorPagesMovie/Migrations/RazorPagesMovieContextModelSnapshot.cs +++ b/RazorPagesMovie/Migrations/RazorPagesMovieContextModelSnapshot.cs @@ -59,14 +59,17 @@ namespace RazorPagesMovie.Migrations b.Property("Message") .IsRequired() - .HasMaxLength(4000) - .HasColumnType("nvarchar(4000)"); + .HasMaxLength(5000) + .HasColumnType("nvarchar(max)"); b.Property("Name") .IsRequired() .HasMaxLength(100) .HasColumnType("nvarchar(100)"); + b.Property("NotificationSent") + .HasColumnType("bit"); + b.Property("Phone") .HasMaxLength(30) .HasColumnType("nvarchar(30)");