Entity Framework(EF)测试DbContext.Database.ExecuteSqlCommand方法删除记录
Entity Framework(EF)测试DbContext.Database.ExecuteSqlCommand方法删除记录C# Code:
using (var context = new UserDbContext())
{
context.Database.Log = Console.Write;
Console.WriteLine("Entity Framework(EF)测试DbContext.Database.ExecuteSqlCommand方法删除记录");
string sql = "DELETE EFUsers WHERE ID=3";
int i = context.Database.ExecuteSqlCommand(sql);
Console.WriteLine("Save Changes Result:" + i.ToString());
Console.ReadLine();
}
若记录不存在,返回0: