File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
Models/Foundations/ReaderBooks Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ //-----------------------------------------------------------
2+ // Copyright (c) Coalition of Good-Hearted Engineers
3+ // Free To Use To Build Reliable Library Management Solutions
4+ //-----------------------------------------------------------
5+
6+ using LibraryManagement . Api . Models . Foundations . ReaderBooks ;
7+ using Microsoft . EntityFrameworkCore ;
8+
9+ namespace LibraryManagement . Api . Brokers . Storages
10+ {
11+ public partial class StorageBroker
12+ {
13+ public DbSet < ReaderBook > ReaderBooks { get ; set ; }
14+ }
15+ }
Original file line number Diff line number Diff line change 44//-----------------------------------------------------------
55
66using EFxceptions ;
7+ using LibraryManagement . Api . Models . Foundations . Books ;
78using Microsoft . EntityFrameworkCore ;
89
910namespace LibraryManagement . Api . Brokers . Storages
@@ -26,6 +27,16 @@ protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
2627 optionsBuilder . UseSqlServer ( connectionString ) ;
2728 }
2829
30+ protected override void OnModelCreating ( ModelBuilder modelBuilder )
31+ {
32+ modelBuilder . Entity < Book > ( )
33+ . HasOne ( b => b . Reader )
34+ . WithMany ( r => r . Books )
35+ . HasForeignKey ( b => b . ReaderId ) ;
36+
37+ base . OnModelCreating ( modelBuilder ) ;
38+ }
39+
2940 public override void Dispose ( ) { }
3041 }
3142}
Original file line number Diff line number Diff line change 1+ //-----------------------------------------------------------
2+ // Copyright (c) Coalition of Good-Hearted Engineers
3+ // Free To Use To Build Reliable Library Management Solutions
4+ //-----------------------------------------------------------
5+
6+ using LibraryManagement . Api . Models . Foundations . Books ;
7+ using LibraryManagement . Api . Models . Foundations . Readers ;
8+
9+ namespace LibraryManagement . Api . Models . Foundations . ReaderBooks
10+ {
11+ public class ReaderBook
12+ {
13+ public Reader Reader { get ; set ; }
14+ public List < Book > Books { get ; set ; }
15+ }
16+ }
You can’t perform that action at this time.
0 commit comments