forked from yangzhongke/NETBookMaterials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b5e30b7
commit dcb92f6
Showing
27 changed files
with
588 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EFcoreOneToOneBug | ||
namespace EFcoreOneToOneBug | ||
{ | ||
class A | ||
{ | ||
public Guid Id { get; set; } | ||
public string Name { get; set; } | ||
public B? B { get; set; } | ||
public Guid? BId { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace EFcoreOneToOneBug | ||
namespace EFcoreOneToOneBug | ||
{ | ||
class B | ||
{ | ||
public Guid Id { get; set; } | ||
public int Age { get; set; } | ||
public A A { get; set; } | ||
public Guid AId { get; set; } | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
最后一章非项目代码/最后一章非项目代码/EFcoreOneToOneBug/Migrations/20211029113915_Init.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
最后一章非项目代码/最后一章非项目代码/EFcoreOneToOneBug/Migrations/20211029113915_Init.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace EFcoreOneToOneBug.Migrations | ||
{ | ||
public partial class Init : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.CreateTable( | ||
name: "A", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), | ||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_A", x => x.Id); | ||
}); | ||
|
||
migrationBuilder.CreateTable( | ||
name: "B", | ||
columns: table => new | ||
{ | ||
Id = table.Column<Guid>(type: "uniqueidentifier", nullable: false), | ||
Age = table.Column<int>(type: "int", nullable: false), | ||
AId = table.Column<Guid>(type: "uniqueidentifier", nullable: false) | ||
}, | ||
constraints: table => | ||
{ | ||
table.PrimaryKey("PK_B", x => x.Id); | ||
table.ForeignKey( | ||
name: "FK_B_A_AId", | ||
column: x => x.AId, | ||
principalTable: "A", | ||
principalColumn: "Id", | ||
onDelete: ReferentialAction.Cascade); | ||
}); | ||
|
||
migrationBuilder.CreateIndex( | ||
name: "IX_B_AId", | ||
table: "B", | ||
column: "AId", | ||
unique: true); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropTable( | ||
name: "B"); | ||
|
||
migrationBuilder.DropTable( | ||
name: "A"); | ||
} | ||
} | ||
} |
83 changes: 83 additions & 0 deletions
83
最后一章非项目代码/最后一章非项目代码/EFcoreOneToOneBug/Migrations/20211029115239_Init2.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
26 changes: 26 additions & 0 deletions
26
最后一章非项目代码/最后一章非项目代码/EFcoreOneToOneBug/Migrations/20211029115239_Init2.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
using System; | ||
using Microsoft.EntityFrameworkCore.Migrations; | ||
|
||
#nullable disable | ||
|
||
namespace EFcoreOneToOneBug.Migrations | ||
{ | ||
public partial class Init2 : Migration | ||
{ | ||
protected override void Up(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.AddColumn<Guid>( | ||
name: "BId", | ||
table: "A", | ||
type: "uniqueidentifier", | ||
nullable: true); | ||
} | ||
|
||
protected override void Down(MigrationBuilder migrationBuilder) | ||
{ | ||
migrationBuilder.DropColumn( | ||
name: "BId", | ||
table: "A"); | ||
} | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
最后一章非项目代码/最后一章非项目代码/EFcoreOneToOneBug/Migrations/MyDbContextModelSnapshot.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// <auto-generated /> | ||
using System; | ||
using EFcoreOneToOneBug; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Infrastructure; | ||
using Microsoft.EntityFrameworkCore.Metadata; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
#nullable disable | ||
|
||
namespace EFcoreOneToOneBug.Migrations | ||
{ | ||
[DbContext(typeof(MyDbContext))] | ||
partial class MyDbContextModelSnapshot : ModelSnapshot | ||
{ | ||
protected override void BuildModel(ModelBuilder modelBuilder) | ||
{ | ||
#pragma warning disable 612, 618 | ||
modelBuilder | ||
.HasAnnotation("ProductVersion", "6.0.0-rc.2.21480.5") | ||
.HasAnnotation("Relational:MaxIdentifierLength", 128); | ||
|
||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); | ||
|
||
modelBuilder.Entity("EFcoreOneToOneBug.A", b => | ||
{ | ||
b.Property<Guid>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("uniqueidentifier"); | ||
b.Property<Guid?>("BId") | ||
.HasColumnType("uniqueidentifier"); | ||
b.Property<string>("Name") | ||
.IsRequired() | ||
.HasColumnType("nvarchar(max)"); | ||
b.HasKey("Id"); | ||
b.ToTable("A"); | ||
}); | ||
|
||
modelBuilder.Entity("EFcoreOneToOneBug.B", b => | ||
{ | ||
b.Property<Guid>("Id") | ||
.ValueGeneratedOnAdd() | ||
.HasColumnType("uniqueidentifier"); | ||
b.Property<Guid>("AId") | ||
.HasColumnType("uniqueidentifier"); | ||
b.Property<int>("Age") | ||
.HasColumnType("int"); | ||
b.HasKey("Id"); | ||
b.HasIndex("AId") | ||
.IsUnique(); | ||
b.ToTable("B"); | ||
}); | ||
|
||
modelBuilder.Entity("EFcoreOneToOneBug.B", b => | ||
{ | ||
b.HasOne("EFcoreOneToOneBug.A", "A") | ||
.WithOne("B") | ||
.HasForeignKey("EFcoreOneToOneBug.B", "AId") | ||
.OnDelete(DeleteBehavior.Cascade) | ||
.IsRequired(); | ||
b.Navigation("A"); | ||
}); | ||
|
||
modelBuilder.Entity("EFcoreOneToOneBug.A", b => | ||
{ | ||
b.Navigation("B"); | ||
}); | ||
#pragma warning restore 612, 618 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.