Relate Users and Orders, + migrations
This commit is contained in:
@@ -49,6 +49,12 @@ public class OrderConfiguration : EntityBaseConfiguration<Order>
|
||||
.WithOne(oa => oa.Order)
|
||||
.HasForeignKey<OrderAddress>(oa => oa.OrderId)
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
builder.HasOne(o => o.User)
|
||||
.WithMany(u => u.Orders)
|
||||
.HasForeignKey(o => o.UserId)
|
||||
.HasPrincipalKey(u => u.Id)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
builder.HasIndex(o => o.UserId)
|
||||
.HasDatabaseName("IX_Order_UserId");
|
||||
|
||||
1033
src/Imprink.Infrastructure/Migrations/20250606162608_RelateUsersAndOrders.Designer.cs
generated
Normal file
1033
src/Imprink.Infrastructure/Migrations/20250606162608_RelateUsersAndOrders.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,30 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Imprink.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class RelateUsersAndOrders : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_User_UserId",
|
||||
table: "Orders",
|
||||
column: "UserId",
|
||||
principalTable: "User",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_User_UserId",
|
||||
table: "Orders");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -867,9 +867,17 @@ namespace Imprink.Infrastructure.Migrations
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Imprink.Domain.Entities.Users.User", "User")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("UserId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("OrderStatus");
|
||||
|
||||
b.Navigation("ShippingStatus");
|
||||
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Imprink.Domain.Entities.Orders.OrderAddress", b =>
|
||||
@@ -1012,6 +1020,8 @@ namespace Imprink.Infrastructure.Migrations
|
||||
{
|
||||
b.Navigation("Addresses");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("UserRoles");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
|
||||
Reference in New Issue
Block a user