File tree Expand file tree Collapse file tree
eventz-api/Eventz.Infrastructure Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11
22using Eventz . Domain . Entitites ;
3+ using Eventz . Infrastructure . Configurations ;
34using Microsoft . EntityFrameworkCore ;
45
56namespace Eventz . Infrastructure
@@ -15,6 +16,12 @@ public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
1516
1617 public DbSet < User > Users => Set < User > ( ) ;
1718
18- //Add Configs
19+ protected override void OnModelCreating ( ModelBuilder modelBuilder )
20+ {
21+ modelBuilder . ApplyConfigurationsFromAssembly ( typeof ( AppDbContext ) . Assembly ) ;
22+
23+ base . OnModelCreating ( modelBuilder ) ;
24+ }
25+
1926 }
2027}
Original file line number Diff line number Diff line change 1+ using Eventz . Domain . Entitites ;
2+ using Microsoft . EntityFrameworkCore ;
3+ using Microsoft . EntityFrameworkCore . Metadata . Builders ;
4+ using System ;
5+ using System . Collections . Generic ;
6+ using System . Linq ;
7+ using System . Text ;
8+ using System . Threading . Tasks ;
9+
10+ namespace Eventz . Infrastructure . Configurations
11+ {
12+ public class UserConfiguration : IEntityTypeConfiguration < User >
13+ {
14+ public void Configure ( EntityTypeBuilder < User > builder )
15+ {
16+ builder . ToTable ( "Users" ) ;
17+
18+ builder . HasKey ( x => x . Id ) ;
19+ builder . HasMany ( u => u . Events ) ;
20+ builder . HasMany ( u => u . Tickets ) ;
21+ builder . HasIndex ( u => u . Email ) . IsUnique ( ) ;
22+ }
23+
24+ }
25+ }
You can’t perform that action at this time.
0 commit comments