Search
 
SCRIPT & CODE EXAMPLE
 

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

    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: exceeds your upload_max_filesize ini directive (limit is 2048 KiB). 
Csharp :: searching for keys in the registry 
Csharp :: C# loop through the registry searching for keys containing 
Csharp :: iframe set html content c# 
Csharp :: update table in C# 
Csharp :: c# list remove by index 
Csharp :: .net 4.5 use tls 1.2 
Csharp :: sealed method in c# 
Csharp :: c# map function 
Csharp :: audio unity 
Csharp :: c# null conditional 
Csharp :: c# access substring 
Csharp :: how to add event function from code in wpf 
Csharp :: global exception handler c# 
Csharp :: run in new thread C# 
Csharp :: batchblock timeout 
Csharp :: c# custom event handler with parameters 
Csharp :: c# filter datagridview 
Csharp :: C# top down view movement 
Csharp :: interop C# save as and replace 
Csharp :: only specific columns in Linq 
Csharp :: print hello world in unity 
Csharp :: .net mvc foreach index 
Csharp :: get current location latitude and longitude in xamarin - NAYCode.com 
Csharp :: how to we put a link in button in a view in asp.net 
Csharp :: BulkWrite c# example mongodb 
Csharp :: C# random multiple of 5 in range 
Csharp :: c# if break 
Csharp :: linq convert list to another list 
Csharp :: winforms combobox get selected text 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =