Correct models unit and recipe and add a new migration

This commit is contained in:
Francesco D'Amico
2025-03-18 16:14:01 +01:00
parent a91ca743ab
commit c498e23a07
6 changed files with 47 additions and 34 deletions
@@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace Francesco.Recipes.World.Migrations
{
[DbContext(typeof(FrancescosRecipesWorldDbContext))]
[Migration("20250318105823_InitialMigration")]
partial class InitialMigration
[Migration("20250318150949_InitialMIgration")]
partial class InitialMIgration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -32,6 +32,7 @@ namespace Francesco.Recipes.World.Migrations
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
@@ -112,6 +113,7 @@ namespace Francesco.Recipes.World.Migrations
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
@@ -147,9 +149,11 @@ namespace Francesco.Recipes.World.Migrations
.HasColumnType("uniqueidentifier");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Number")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<Guid>("RecipeId")
@@ -219,7 +223,11 @@ namespace Francesco.Recipes.World.Migrations
b.Property<bool>("IsFavorite")
.HasColumnType("bit");
b.Property<DateTime?>("ModifiedAt")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<TimeSpan>("PreparationTime")
@@ -275,6 +283,9 @@ namespace Francesco.Recipes.World.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<DateTime?>("ModifiedAt")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("ShoppingLists");
@@ -287,9 +298,11 @@ namespace Francesco.Recipes.World.Migrations
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Symbol")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
@@ -8,12 +8,12 @@ using Microsoft.EntityFrameworkCore.Migrations;
namespace Francesco.Recipes.World.Migrations
{
/// <inheritdoc />
public partial class InitialMigration : Migration
public partial class InitialMIgration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
if (migrationBuilder == null)
if (migrationBuilder is null)
{
throw new ArgumentNullException(nameof(migrationBuilder));
}
@@ -22,7 +22,7 @@ namespace Francesco.Recipes.World.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true)
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
@@ -46,7 +46,7 @@ namespace Francesco.Recipes.World.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true)
Name = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
@@ -58,7 +58,8 @@ namespace Francesco.Recipes.World.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false)
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: true)
},
constraints: table =>
{
@@ -70,8 +71,8 @@ namespace Francesco.Recipes.World.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
Symbol = table.Column<string>(type: "nvarchar(max)", nullable: true)
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Symbol = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
@@ -83,7 +84,7 @@ namespace Francesco.Recipes.World.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
Difficulty = table.Column<int>(type: "int", nullable: false),
Servings = table.Column<int>(type: "int", nullable: false),
@@ -91,6 +92,7 @@ namespace Francesco.Recipes.World.Migrations
CookingTime = table.Column<TimeSpan>(type: "time", nullable: false),
IsFavorite = table.Column<bool>(type: "bit", nullable: false),
CreatedAt = table.Column<DateTime>(type: "datetime2", nullable: false),
ModifiedAt = table.Column<DateTime>(type: "datetime2", nullable: true),
FavoritId = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
CategoryId = table.Column<Guid>(type: "uniqueidentifier", nullable: true)
},
@@ -140,8 +142,8 @@ namespace Francesco.Recipes.World.Migrations
columns: table => new
{
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
Number = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: false),
Number = table.Column<string>(type: "nvarchar(max)", nullable: false),
RecipeId = table.Column<Guid>(type: "uniqueidentifier", nullable: false)
},
constraints: table =>
@@ -304,7 +306,7 @@ namespace Francesco.Recipes.World.Migrations
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
if (migrationBuilder == null)
if (migrationBuilder is null)
{
throw new ArgumentNullException(nameof(migrationBuilder));
}
@@ -29,6 +29,7 @@ namespace Francesco.Recipes.World.Migrations
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
@@ -109,6 +110,7 @@ namespace Francesco.Recipes.World.Migrations
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
@@ -144,9 +146,11 @@ namespace Francesco.Recipes.World.Migrations
.HasColumnType("uniqueidentifier");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Number")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<Guid>("RecipeId")
@@ -216,7 +220,11 @@ namespace Francesco.Recipes.World.Migrations
b.Property<bool>("IsFavorite")
.HasColumnType("bit");
b.Property<DateTime?>("ModifiedAt")
.HasColumnType("datetime2");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<TimeSpan>("PreparationTime")
@@ -272,6 +280,9 @@ namespace Francesco.Recipes.World.Migrations
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime2");
b.Property<DateTime?>("ModifiedAt")
.HasColumnType("datetime2");
b.HasKey("Id");
b.ToTable("ShoppingLists");
@@ -284,9 +295,11 @@ namespace Francesco.Recipes.World.Migrations
.HasColumnType("uniqueidentifier");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Symbol")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");