Simple way to define EF Core Relationships

Hey /r/csharp

I am currently doing some work with EF Core in a ASP NET Core MVC project. I currently have about ~20 relationships defined in the dbcontext as follows:

//User -> Referral modelBuilder.Entity<User>() .HasOne<Referral>() .WithOne(x => x.User) .OnDelete(DeleteBehavior.Cascade); 

Now I am planning on adding more tables to this DB, is there a way I can maybe define these relationships with reflection once and it will apply the rule to all relationships between tables?

submitted by /u/thezadmin
[link] [comments]

Leave a Reply