-
Notifications
You must be signed in to change notification settings - Fork 22
Entity Framework Core for Console
L edited this page Oct 10, 2019
·
1 revision
Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.Tools
public class WebCrawlerDbContext : DbContext
{
public DbSet<TableName> YourTable { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlServer(@"Server=; Database=DbName; User ID=sa; Password=;");
}
}
迁移
add-migration xxx
update-database
using (var context = new WebCrawlerDbContext())
{
//do something
context.SaveChanges();
}