Answers for "where to write fluent api"

C#
1

where to write fluent api

public class OfficeContext: DbContext 
{

   
  	public virtual DbSet<Course> Courses { get; set; }
    public virtual DbSet<Enrollment> Enrollments { get; set; }
    public virtual DbSet<Student> Students { get; set; }
  	public virtual DbSet<Worker> Workers { get; set; }
        
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
         //Write Fluent API configurations here
      	 //some example of fluent api
      	 //Configure default schema
         modelBuilder.HasDefaultSchema("Admin");

         //Map entity to table
         modelBuilder.Entity<Student>().ToTable("StudentsInfo");
         modelBuilder.Entity<Course>().ToTable("CoursesInfo");
         modelBuilder.Entity<Enrollment>().ToTable("EnrollmentsInfo");
      	 modelBuilder.Entity<Enrollment>().ToTable("WorkersInfo");

    }
}
Posted by: Guest on May-04-2022

Code answers related to "where to write fluent api"

C# Answers by Framework

Browse Popular Code Answers by Language