方法一:在快速监视中查看db.entry(entity).getvalidationresult() public class NewsDal { public static News Add(News entity) { using (CmsContext db = new CmsContext()) { News news = new News(); try { news = db.News.Add(entity); db.SaveChanges
方法一:在快速监视中查看db.entry(entity).getvalidationresult()
public class NewsDal
{
public static News Add(News entity)
{
using (CmsContext db = new CmsContext())
{
News news = new News();
try
{
news = db.News.Add(entity);
db.SaveChanges();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
return news;
}
}
}
快速监视中查看:db.Entry(entity).GetValidationResult()

AlegroCart新功能:维类:包括在这两种线性长宽高或面积或体积长波产品尺寸允许与期权产品:让产品/期权组合独特的数量,尺寸,图像和型号。选择店铺标识管理 图片放大镜:显示一个图片放大上空盘旋时,产品形象弹出框。自定义错误报告:设置在管理员启用。 开发者只可以显示详细的信息。错误信息都写入到错误日志文件每天可以通过电子邮件发送给管理员。仓库皮卡航运模块:允许客户指定产品在商店的位置回升。增加了
方法二:直接catch (DbEntityValidationException ex) 前提先引用:using System.Data.Entity.Validation;
public class NewsDal
{
public static News Add(News entity)
{
using (CmsContext db = new CmsContext())
{
News news = new News();
try
{
news = db.News.Add(entity);
db.SaveChanges();
}
//catch (Exception ex)
catch (DbEntityValidationException ex)
{
throw new Exception(ex.Message);
}
return news;
}
}
}









