mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-03-25 10:21:11 -04:00
Make fields readonly Remove unnecessary casts Format document Remove unnecessary usings Sort usings Use file-level namespaces Order modifiers
26 lines
658 B
C#
26 lines
658 B
C#
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
|
|
|
namespace DataLayer.Configurations;
|
|
|
|
internal class BookCategoryConfig : IEntityTypeConfiguration<BookCategory>
|
|
{
|
|
public void Configure(EntityTypeBuilder<BookCategory> entity)
|
|
{
|
|
entity.HasKey(bc => new { bc.BookId, bc.CategoryLadderId });
|
|
|
|
entity.HasIndex(bc => bc.BookId);
|
|
entity.HasIndex(bc => bc.CategoryLadderId);
|
|
|
|
entity
|
|
.HasOne(bc => bc.Book)
|
|
.WithMany(b => b.CategoriesLink)
|
|
.HasForeignKey(bc => bc.BookId);
|
|
|
|
entity
|
|
.HasOne(bc => bc.CategoryLadder)
|
|
.WithMany(c => c.BooksLink)
|
|
.HasForeignKey(bc => bc.CategoryLadderId);
|
|
}
|
|
}
|