11 July 2017

DB Context (ASP.NET MVC vs. ASP.NET Core MVC)

ASP.NET MVC

using System.Data.Entity;   

public class ProfileContext : DbContext
{
    public ProfileContext() : base("ProfileConnectionString")
    {
    }

    public DbSet<Profile> Profiles { get; set; }

    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Profile>().ToTable("Profile");        
    }
}


ASP.NET Core MVC

using Microsoft.EntityFrameworkCore;

public class ProfileContext : DbContext
{
    public ProfileContext(DbContextOptions<ProfileContext> options) : base(options)
    {
    }

    public DbSet<Profile> Profiles { get; set; }

    protected override void OnModelCreating(ModelBuilder modelBuilder)
    {
        modelBuilder.Entity<Profile>().ToTable("Profile");
    }
}


1 comment:

  1. BetMGM launches live dealer studio in West Memphis - JTM Hub
    BetMGM is launching an expanded sports 속초 출장마사지 betting and live 의왕 출장안마 casino 파주 출장안마 experience. 여수 출장샵 BetMGM is also the first online 경기도 출장샵 betting

    ReplyDelete