Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

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");

    }
}
 
PREVIOUS NEXT
Tagged: #write #fluent #api
ADD COMMENT
Topic
Name
1+9 =