Entity Framework/MVC3: temporarily disable validation

前端 未结 1 814
余生分开走
余生分开走 2020-12-08 06:42

I am using EF Code First. I heavily use code annotations to specify how the data (model) should be validated. However, often I just need validation at UI layer and be able t

相关标签:
1条回答
  • 2020-12-08 07:36

    You just need to set Configuration.ValidateOnSaveEnabled = false in your context class before calling SaveChanges().

    context.Configuration.ValidateOnSaveEnabled = false;
    context.SaveChanges();
    
    0 讨论(0)
提交回复
热议问题