📜  在 Entity Framework Core 的数据库中插入多条记录 - 无论代码示例

📅  最后修改于: 2022-03-11 14:59:14.927000             🧑  作者: Mango

代码示例1
var dept1 = new Department() { Name = "Development" };
var dept2 = new Department() { Name = "HR" };
var dept3 = new Department() { Name = "Marketing" };
 
using (var context = new CompanyContext())
{
    context.Department.AddRange(dept1, dept2, dept3);
    context.SaveChanges();
}