26 lines
849 B
C#
26 lines
849 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
using OnProfNext.Shared.Models;
|
|
|
|
namespace OnProfNext.Server.Configurations
|
|
{
|
|
public class OrderUserConfiguration : IEntityTypeConfiguration<OrderUser>
|
|
{
|
|
public void Configure(EntityTypeBuilder<OrderUser> entity)
|
|
{
|
|
entity.ToTable("OrderUsers");
|
|
entity.HasKey(ou => new { ou.OrderId, ou.UserId });
|
|
|
|
entity.HasOne(ou => ou.Order)
|
|
.WithMany(o => o.OrderUsers)
|
|
.HasForeignKey(ou => ou.OrderId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
|
|
entity.HasOne(ou => ou.User)
|
|
.WithMany()
|
|
.HasForeignKey(ou => ou.UserId)
|
|
.OnDelete(DeleteBehavior.Cascade);
|
|
}
|
|
}
|
|
}
|