perform and apply database migrations

This commit is contained in:
2023-10-31 16:27:14 -05:00
parent 1d5404ef03
commit 7443fc4b9c
18 changed files with 1410 additions and 9 deletions

View File

@@ -0,0 +1,111 @@
// <auto-generated />
using FakePieShop.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FakePieShop.Migrations
{
[DbContext(typeof(FakePieShopDbContext))]
[Migration("20231031205035_InitialMigration")]
partial class InitialMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("FakePieShop.Models.Category", b =>
{
b.Property<int>("CategoryId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CategoryId"));
b.Property<string>("CategoryName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.HasKey("CategoryId");
b.ToTable("Categories");
});
modelBuilder.Entity("FakePieShop.Models.Pie", b =>
{
b.Property<int>("PieId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("PieId"));
b.Property<string>("AllergyInformation")
.HasColumnType("nvarchar(max)");
b.Property<int>("CategoryId")
.HasColumnType("int");
b.Property<string>("ImageThumbnailUrl")
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.HasColumnType("nvarchar(max)");
b.Property<bool>("InStock")
.HasColumnType("bit");
b.Property<bool>("IsPieOfTheWeek")
.HasColumnType("bit");
b.Property<string>("LongDescription")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Price")
.HasColumnType("decimal(18,2)");
b.Property<string>("ShortDescription")
.HasColumnType("nvarchar(max)");
b.HasKey("PieId");
b.HasIndex("CategoryId");
b.ToTable("Pies");
});
modelBuilder.Entity("FakePieShop.Models.Pie", b =>
{
b.HasOne("FakePieShop.Models.Category", "Category")
.WithMany("Pies")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Category");
});
modelBuilder.Entity("FakePieShop.Models.Category", b =>
{
b.Navigation("Pies");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -0,0 +1,71 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace FakePieShop.Migrations
{
/// <inheritdoc />
public partial class InitialMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Categories",
columns: table => new
{
CategoryId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CategoryName = table.Column<string>(type: "nvarchar(max)", nullable: false),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Categories", x => x.CategoryId);
});
migrationBuilder.CreateTable(
name: "Pies",
columns: table => new
{
PieId = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
ShortDescription = table.Column<string>(type: "nvarchar(max)", nullable: true),
LongDescription = table.Column<string>(type: "nvarchar(max)", nullable: true),
AllergyInformation = table.Column<string>(type: "nvarchar(max)", nullable: true),
Price = table.Column<decimal>(type: "decimal(18,2)", nullable: false),
ImageUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
ImageThumbnailUrl = table.Column<string>(type: "nvarchar(max)", nullable: true),
IsPieOfTheWeek = table.Column<bool>(type: "bit", nullable: false),
InStock = table.Column<bool>(type: "bit", nullable: false),
CategoryId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Pies", x => x.PieId);
table.ForeignKey(
name: "FK_Pies_Categories_CategoryId",
column: x => x.CategoryId,
principalTable: "Categories",
principalColumn: "CategoryId",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Pies_CategoryId",
table: "Pies",
column: "CategoryId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Pies");
migrationBuilder.DropTable(
name: "Categories");
}
}
}

View File

@@ -0,0 +1,108 @@
// <auto-generated />
using FakePieShop.Models;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace FakePieShop.Migrations
{
[DbContext(typeof(FakePieShopDbContext))]
partial class FakePieShopDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "7.0.13")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("FakePieShop.Models.Category", b =>
{
b.Property<int>("CategoryId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("CategoryId"));
b.Property<string>("CategoryName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.HasKey("CategoryId");
b.ToTable("Categories");
});
modelBuilder.Entity("FakePieShop.Models.Pie", b =>
{
b.Property<int>("PieId")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("PieId"));
b.Property<string>("AllergyInformation")
.HasColumnType("nvarchar(max)");
b.Property<int>("CategoryId")
.HasColumnType("int");
b.Property<string>("ImageThumbnailUrl")
.HasColumnType("nvarchar(max)");
b.Property<string>("ImageUrl")
.HasColumnType("nvarchar(max)");
b.Property<bool>("InStock")
.HasColumnType("bit");
b.Property<bool>("IsPieOfTheWeek")
.HasColumnType("bit");
b.Property<string>("LongDescription")
.HasColumnType("nvarchar(max)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<decimal>("Price")
.HasColumnType("decimal(18,2)");
b.Property<string>("ShortDescription")
.HasColumnType("nvarchar(max)");
b.HasKey("PieId");
b.HasIndex("CategoryId");
b.ToTable("Pies");
});
modelBuilder.Entity("FakePieShop.Models.Pie", b =>
{
b.HasOne("FakePieShop.Models.Category", "Category")
.WithMany("Pies")
.HasForeignKey("CategoryId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Category");
});
modelBuilder.Entity("FakePieShop.Models.Category", b =>
{
b.Navigation("Pies");
});
#pragma warning restore 612, 618
}
}
}

View File

@@ -5,7 +5,9 @@ namespace FakePieShop.Models
public class FakePieShopDbContext : DbContext
{
// no further configuration needed for this constructor; all is handled by the superclass
public FakePieShopDbContext(DbContextOptions<FakePieShopDbContext> options) : base(options) {}
public FakePieShopDbContext(DbContextOptions<FakePieShopDbContext> options) : base(options)
{
}
public DbSet<Category> Categories { get; set; }
public DbSet<Pie> Pies { get; set; }

View File

@@ -11,7 +11,7 @@ builder.Services.AddControllersWithViews();
builder.Services.AddDbContext<FakePieShopDbContext>(options =>
{
options.UseSqlServer(
builder.Configuration["ConnectionStrings:FakePieShopDbContextConnection"])
builder.Configuration["ConnectionStrings:FakePieShopDbContextConnection"]);
});
WebApplication app = builder.Build();

View File

@@ -7,6 +7,6 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"FakePieShopDbContextConnection": "Server=(localdb)\\mysqllocaldb;\\Database=FakePieShop0123456;Trusted_Connection=true;Multiple_Active_Results=true;"
"FakePieShopDbContextConnection": "Server=(localdb)\\mssqllocaldb;Database=FakePieShop0123456;Trusted_Connection=true;MultipleActiveResultSets=true"
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -13,6 +13,7 @@
],
"configProperties": {
"System.GC.Server": true,
"System.Reflection.NullabilityInfoContext.IsSupported": true,
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
}
}

View File

@@ -5,5 +5,8 @@
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
"AllowedHosts": "*",
"ConnectionStrings": {
"FakePieShopDbContextConnection": "Server=(localdb)\\mssqllocaldb;Database=FakePieShop0123456;Trusted_Connection=true;MultipleActiveResultSets=true"
}
}

View File

@@ -27,3 +27,60 @@ C:\Users\mikay\source\repos\FakePieShop\FakePieShop\obj\Debug\net6.0\FakePieShop
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\obj\Debug\net6.0\FakePieShop.genruntimeconfig.cache
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\obj\Debug\net6.0\ref\FakePieShop.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\libman.json
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\obj\Debug\net6.0\FakePieShop.csproj.AssemblyReference.cache
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Azure.Core.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Azure.Identity.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Humanizer.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Bcl.AsyncInterfaces.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Data.SqlClient.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.EntityFrameworkCore.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.EntityFrameworkCore.Abstractions.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.EntityFrameworkCore.Design.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.EntityFrameworkCore.Relational.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.EntityFrameworkCore.SqlServer.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.Caching.Abstractions.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.Caching.Memory.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.Configuration.Abstractions.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.DependencyInjection.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.DependencyModel.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.Logging.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.Logging.Abstractions.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.Options.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Extensions.Primitives.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Identity.Client.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Identity.Client.Extensions.Msal.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.IdentityModel.Abstractions.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.IdentityModel.JsonWebTokens.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.IdentityModel.Logging.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.IdentityModel.Protocols.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.IdentityModel.Protocols.OpenIdConnect.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.IdentityModel.Tokens.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.SqlServer.Server.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Microsoft.Win32.SystemEvents.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\Mono.TextTemplating.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.CodeDom.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.Configuration.ConfigurationManager.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.Drawing.Common.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.IdentityModel.Tokens.Jwt.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.Memory.Data.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.Runtime.Caching.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.Security.Cryptography.ProtectedData.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.Security.Permissions.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.Text.Encodings.Web.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.Text.Json.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\System.Windows.Extensions.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\unix\lib\net6.0\Microsoft.Data.SqlClient.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win\lib\net6.0\Microsoft.Data.SqlClient.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win-arm\native\Microsoft.Data.SqlClient.SNI.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win-arm64\native\Microsoft.Data.SqlClient.SNI.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win-x64\native\Microsoft.Data.SqlClient.SNI.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win-x86\native\Microsoft.Data.SqlClient.SNI.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win\lib\net6.0\Microsoft.Win32.SystemEvents.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\unix\lib\net6.0\System.Drawing.Common.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win\lib\net6.0\System.Drawing.Common.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win\lib\net6.0\System.Runtime.Caching.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win\lib\net6.0\System.Security.Cryptography.ProtectedData.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\browser\lib\net6.0\System.Text.Encodings.Web.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\bin\Debug\net6.0\runtimes\win\lib\net6.0\System.Windows.Extensions.dll
C:\Users\mikay\source\repos\FakePieShop\FakePieShop\obj\Debug\net6.0\FakePieShop.csproj.CopyComplete

View File

@@ -50,6 +50,8 @@
"version": "[7.0.13, )"
},
"Microsoft.EntityFrameworkCore.Tools": {
"include": "Runtime, Build, Native, ContentFiles, Analyzers, BuildTransitive",
"suppressParent": "All",
"target": "Package",
"version": "[7.0.13, )"
}

View File

@@ -49,7 +49,7 @@
"Humanizer.Core/2.14.1": {
"type": "package",
"compile": {
"lib/net6.0/Humanizer.dll": {
"lib/net6.0/_._": {
"related": ".xml"
}
},
@@ -192,7 +192,7 @@
"Mono.TextTemplating": "2.2.1"
},
"compile": {
"lib/net6.0/Microsoft.EntityFrameworkCore.Design.dll": {
"lib/net6.0/_._": {
"related": ".xml"
}
},
@@ -354,7 +354,7 @@
"System.Text.Json": "7.0.0"
},
"compile": {
"lib/net6.0/Microsoft.Extensions.DependencyModel.dll": {
"lib/net6.0/_._": {
"related": ".xml"
}
},
@@ -635,7 +635,7 @@
"System.CodeDom": "4.4.0"
},
"compile": {
"lib/netstandard2.0/Mono.TextTemplating.dll": {}
"lib/netstandard2.0/_._": {}
},
"runtime": {
"lib/netstandard2.0/Mono.TextTemplating.dll": {}
@@ -644,7 +644,7 @@
"System.CodeDom/4.4.0": {
"type": "package",
"compile": {
"ref/netstandard2.0/System.CodeDom.dll": {
"ref/netstandard2.0/_._": {
"related": ".xml"
}
},