Entity Framework Core doesn't validate data when saving?

后端 未结 1 655
面向向阳花
面向向阳花 2021-01-12 09:23

I have the following remote validation rule:

[AcceptVerbs(\"Get\", \"Post\")]
public IActionResult ValidateWindowEndDate(DateTime? endDate, DateTime? startDa         


        
相关标签:
1条回答
  • 2021-01-12 09:39

    So, this turns out to be a change in the way EF works in Core. It now no longer does validation at all, that is left up to the Client and server (via Model.State). Rowan Miller explains that decision in the EF repo as follows:

    In EF Core we dropped doing validation since it is usually already done client-side, server-side, and then in the database too.

    I can't use the model state in my particular scenario, so instead I've tried to get Remote validation working manually via the Validator object, but I'm not having any luck with that either. More on that in this question: Validator.TryValidateObject does not call Remote validation.

    0 讨论(0)
提交回复
热议问题