/// <summary>
/// 添加操作
/// </summary>
public static void f1()
{
//1.新建一个对象
tbStu stu = new tbStu()
{
stuID = "1",
stuName = "某某某",
stuAddress = "湖南衡阳",
stuTel = "1233554466"
};
//2.执行添加操作
using (nCovDBEntities1 db = new nCovDBEntities1())
{
db.tbStu.Add(stu);
//保存
db.SaveChanges();
Console.WriteLine("添加成功");
}
}
/// <summary>
/// 添加操作
/// </summary>
public static void f2()
{
//1.新建一个对象
tbTea tbTea = new tbTea()
{
teaName="彭某某"
};
//2.执行添加操作
using (nCovDBEntities1 db = new nCovDBEntities1())
{
db.tbTea.Add(tbTea);
//保存
db.SaveChanges();
Console.WriteLine("添加成功");
}
}
EF数据模拟添加
最新推荐文章于 2024-08-08 20:23:02 发布