Answers for "Configure Column Name, Type and Order Entity FrameWork"

C#
0

Configure Column Name, Type and Order Entity FrameWork

public class SchoolContext: DbContext 
{
    public SchoolDBContext(): base() 
    {
    }

    public DbSet<Student> Students { get; set; }
    public DbSet<Standard> Standards { get; set; }
        
    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        //Configure Column
        modelBuilder.Entity<Student>()
                    .Property(p => p.DateOfBirth)
                    .HasColumnName("DoB")
                    .HasColumnOrder(3)
                    .HasColumnType("datetime2");
    }
}
Posted by: Guest on September-18-2021

Code answers related to "Configure Column Name, Type and Order Entity FrameWork"

C# Answers by Framework

Browse Popular Code Answers by Language