Nuget引用

LinqKit.Microsoft.EntityFrameworkCore

Microsoft.EntityFrameworkCore.SqlServer

然后新建类继承DbContext

services.AddMvc();

public class STDbContext:DbContext

  public STDbContext() {

  } 

public virtual DbSet<User> Users { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder){

optionsBuilder.UseSqlServer("Data Source=.;Initial Catalog=Test;User ID=sa,Password=; ");

base.OnConfiguring(optionsBuilder);

}

05-28 07:36