4
4
using System . Text ;
5
5
using Core . Entities . Concrete ;
6
6
using Entities . Concrete ;
7
+ using DataAccess . Dal . EntityFramework . EntityConfigurations ;
7
8
8
9
namespace DataAccess . Dal . EntityFramework . Contexts
9
10
{
@@ -19,14 +20,16 @@ public PhotoChannelContext()
19
20
}
20
21
protected override void OnModelCreating ( ModelBuilder modelBuilder )
21
22
{
22
- modelBuilder . HasDefaultSchema ( "PhotoChannel" ) ;
23
- modelBuilder . Entity < Photo > ( ) . HasOne < User > ( photo => photo . User ) . WithMany ( user => user . Photos ) . OnDelete ( DeleteBehavior . NoAction ) ;
24
- modelBuilder . Entity < Subscriber > ( ) . HasOne < User > ( s => s . User ) . WithMany ( u => u . Subscribers ) . OnDelete ( DeleteBehavior . NoAction ) ;
25
- modelBuilder . Entity < Subscriber > ( ) . HasOne < Channel > ( s => s . Channel ) . WithMany ( u => u . Subscribers ) . OnDelete ( DeleteBehavior . NoAction ) ;
26
- modelBuilder . Entity < Comment > ( ) . HasOne < Photo > ( c => c . Photo ) . WithMany ( p => p . Comments ) . OnDelete ( DeleteBehavior . NoAction ) ;
27
- modelBuilder . Entity < Comment > ( ) . HasOne < User > ( c => c . User ) . WithMany ( u => u . Comments ) . OnDelete ( DeleteBehavior . NoAction ) ;
28
- modelBuilder . Entity < Like > ( ) . HasOne < User > ( l => l . User ) . WithMany ( u => u . Likes ) . OnDelete ( DeleteBehavior . NoAction ) ;
29
- modelBuilder . Entity < Like > ( ) . HasOne < Photo > ( l => l . Photo ) . WithMany ( u => u . Likes ) . OnDelete ( DeleteBehavior . NoAction ) ;
23
+ modelBuilder . ApplyConfiguration ( new CategoryEntityTypeConfiguration ( ) ) ;
24
+ modelBuilder . ApplyConfiguration ( new ChannelEntityTypeConfiguration ( ) ) ;
25
+ modelBuilder . ApplyConfiguration ( new ChannelCategoryEntityTypeConfiguration ( ) ) ;
26
+ modelBuilder . ApplyConfiguration ( new CommentEntityTypeConfiguration ( ) ) ;
27
+ modelBuilder . ApplyConfiguration ( new LikeEntityTypeConfiguration ( ) ) ;
28
+ modelBuilder . ApplyConfiguration ( new OperationClaimEntityTypeConfiguration ( ) ) ;
29
+ modelBuilder . ApplyConfiguration ( new UserOperationClaimEntityTypeConfiguration ( ) ) ;
30
+ modelBuilder . ApplyConfiguration ( new UserEntityTypeConfiguration ( ) ) ;
31
+ modelBuilder . ApplyConfiguration ( new PhotoEntityTypeConfiguration ( ) ) ;
32
+ modelBuilder . ApplyConfiguration ( new SubscriberEntityTypeConfiguration ( ) ) ;
30
33
31
34
modelBuilder . Entity < Category > ( ) . HasData ( new List < Category >
32
35
{
@@ -41,8 +44,10 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
41
44
new OperationClaim { Id = 1 , ClaimName = "Admin" } ,
42
45
new OperationClaim { Id = 2 , ClaimName = "Users" }
43
46
} ) ;
44
- }
45
47
48
+ base . OnModelCreating ( modelBuilder ) ;
49
+ }
50
+
46
51
public DbSet < User > Users { get ; set ; }
47
52
public DbSet < OperationClaim > OperationClaims { get ; set ; }
48
53
public DbSet < UserOperationClaim > UserOperationClaims { get ; set ; }
@@ -53,9 +58,5 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
53
58
public DbSet < Like > Likes { get ; set ; }
54
59
public DbSet < Subscriber > Subscribers { get ; set ; }
55
60
public DbSet < ChannelCategory > ChannelCategories { get ; set ; }
56
-
57
-
58
-
59
-
60
61
}
61
62
}
0 commit comments