Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workshop - All unit tests passes #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

102 changes: 102 additions & 0 deletions EF.Core.Training.CodeShop/Migrations/20220312180836_AddMissingItems.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace EF.Core.Training.Migrations
{
public partial class AddMissingItems : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Title",
table: "Book",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);

migrationBuilder.AlterColumn<string>(
name: "ISBN",
table: "Book",
type: "TEXT",
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "TEXT",
oldNullable: true);

migrationBuilder.CreateTable(
name: "Author",
columns: table => new
{
ID = table.Column<int>(type: "INTEGER", nullable: false)
.Annotation("Sqlite:Autoincrement", true),
Name = table.Column<string>(type: "TEXT", nullable: false),
First = table.Column<string>(type: "TEXT", nullable: true),
Last = table.Column<string>(type: "TEXT", nullable: true),
Bio = table.Column<string>(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Author", x => x.ID);
});

migrationBuilder.CreateTable(
name: "AuthorBookLink",
columns: table => new
{
AuthorID = table.Column<int>(type: "INTEGER", nullable: false),
BookID = table.Column<int>(type: "INTEGER", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AuthorBookLink", x => new { x.AuthorID, x.BookID });
table.ForeignKey(
name: "FK_AuthorBookLink_Author_AuthorID",
column: x => x.AuthorID,
principalTable: "Author",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AuthorBookLink_Book_BookID",
column: x => x.BookID,
principalTable: "Book",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
});

migrationBuilder.CreateIndex(
name: "IX_AuthorBookLink_BookID",
table: "AuthorBookLink",
column: "BookID");
}

protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AuthorBookLink");

migrationBuilder.DropTable(
name: "Author");

migrationBuilder.AlterColumn<string>(
name: "Title",
table: "Book",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT");

migrationBuilder.AlterColumn<string>(
name: "ISBN",
table: "Book",
type: "TEXT",
nullable: true,
oldClrType: typeof(string),
oldType: "TEXT");
}
}
}
67 changes: 67 additions & 0 deletions EF.Core.Training.CodeShop/Migrations/ApiContextModelSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,45 @@ protected override void BuildModel(ModelBuilder modelBuilder)
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "6.0.1");

modelBuilder.Entity("EF.Core.Training.BlackBox.Author", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");

b.Property<string>("Bio")
.HasColumnType("TEXT");

b.Property<string>("First")
.HasColumnType("TEXT");

b.Property<string>("Last")
.HasColumnType("TEXT");

b.Property<string>("Name")
.IsRequired()
.HasColumnType("TEXT");

b.HasKey("ID");

b.ToTable("Author", (string)null);
});

modelBuilder.Entity("EF.Core.Training.BlackBox.AuthorBookLink", b =>
{
b.Property<int>("AuthorID")
.HasColumnType("INTEGER");

b.Property<int>("BookID")
.HasColumnType("INTEGER");

b.HasKey("AuthorID", "BookID");

b.HasIndex("BookID");

b.ToTable("AuthorBookLink", (string)null);
});

modelBuilder.Entity("EF.Core.Training.BlackBox.Book", b =>
{
b.Property<int>("ID")
Expand All @@ -26,6 +65,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("TEXT");

b.Property<string>("ISBN")
.IsRequired()
.HasColumnType("TEXT");

b.Property<int>("Pages")
Expand All @@ -35,6 +75,7 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.HasColumnType("TEXT");

b.Property<string>("Title")
.IsRequired()
.HasColumnType("TEXT");

b.HasKey("ID");
Expand Down Expand Up @@ -72,6 +113,25 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.ToTable("Genre", (string)null);
});

modelBuilder.Entity("EF.Core.Training.BlackBox.AuthorBookLink", b =>
{
b.HasOne("EF.Core.Training.BlackBox.Author", "Author")
.WithMany("BookLinks")
.HasForeignKey("AuthorID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.HasOne("EF.Core.Training.BlackBox.Book", "Book")
.WithMany("AuthorLinks")
.HasForeignKey("BookID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("Author");

b.Navigation("Book");
});

modelBuilder.Entity("EF.Core.Training.BlackBox.BookGenreLink", b =>
{
b.HasOne("EF.Core.Training.BlackBox.Book", "Book")
Expand All @@ -91,8 +151,15 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Navigation("Genre");
});

modelBuilder.Entity("EF.Core.Training.BlackBox.Author", b =>
{
b.Navigation("BookLinks");
});

modelBuilder.Entity("EF.Core.Training.BlackBox.Book", b =>
{
b.Navigation("AuthorLinks");

b.Navigation("GenreLinks");
});

Expand Down
Loading