Usage of existing database (not database first)
1. create class which is inheirt from DBContext, make sure there is an database connection which is named of xxxx
public class SimpleContext : DbContext { public SimpleContext() : base("name=xxxx") { Database.SetInitializer<SimpleContext>(null); } protected override void OnModelCreating(DbModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); } public virtual DbSet<Product> Product{ get; set; } }
2. add mapped dataTable, schema and primary key

浙公网安备 33010602011771号