包
Microsoft.EntityFrameworkCore
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.Tools
DbContext
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();
}
查询相关内容:加载相关数据