Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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 :: get file name from stream c# 
Csharp :: finding keys in the registry 
Csharp :: c# creating an array 
Csharp :: how to sort a dictionary by value in c# 
Csharp :: c# destroy function...unity 
Csharp :: password regex asp.net 
Csharp :: how to decrease velocity of a Unity rigidbody 
Csharp :: onmousedown not working unity 
Csharp :: math with c sharp 
Csharp :: c# generic return type in interface 
Csharp :: .net on vs code 
Csharp :: Get Mac address of Device in Xamarin 
Csharp :: setting the parent of a transform which resides in a prefab 
Csharp :: C# Linq item index 
Csharp :: render world space UI infront of everything unity 
Csharp :: getelement video 
Csharp :: wpf textbox insert text at caret position 
Csharp :: c# json 
Csharp :: store data between razor pages 
Csharp :: declarar lista c# 
Csharp :: how to know pm or am C# 
Csharp :: unity cannot click button 
Csharp :: Ignore case string linq c# 
Csharp :: c# multiplicate char 
Csharp :: uwp roaming data sample 
Csharp :: Get a list of distinct values in List 
Csharp :: android jaca how to pass a imageurl in a recyclerview adapter 
Csharp :: c# get private property 
Csharp :: SQLite Parameters 
Csharp :: fill dictionary c# 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =