Validation Error on SaveChanges()

前端 未结 3 1301
时光说笑
时光说笑 2020-12-23 02:35

I have the following Action method inside my Asp.net mvc web application:-

[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Create(SDJoin sdj, FormC         


        
3条回答
  •  再見小時候
    2020-12-23 02:46

    Although this is an old post but this approach can be more fruitful!

    Credits

    Try something like this

            try
            {
                pcontext.SaveChanges();
            }
           catch (System.Data.Entity.Infrastructure.DbUpdateConcurrencyException ex)
            {             
                 Console.WriteLine(ex.InnerException);
            }
            catch (System.Data.Entity.Core.EntityCommandCompilationException ex)
            {
              Console.WriteLine(ex.InnerException);
            }
            catch (System.Data.Entity.Core.UpdateException ex)
            {
             Console.WriteLine(ex.InnerException);
            }
    
            catch (System.Data.Entity.Infrastructure.DbUpdateException ex) //DbContext
            {
                Console.WriteLine(ex.InnerException);
            }
    
            catch (Exception ex)
            {
                Console.WriteLine(ex.InnerException);
                throw;
            }
    

提交回复
热议问题