locked
Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. RRS feed

  • Question

  • User-1818064326 posted

    by debugging i get null values in my fields but this same code works for my other application.

    plz guide thanks in advance.  

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

    Exception Details: System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.

    Source Error: 

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


    Stack Trace: 

    [DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.]
       System.Data.Entity.Internal.InternalContext.SaveChanges() +169
       System.Data.Entity.Internal.LazyInternalContext.SaveChanges() +33
       System.Data.Entity.DbContext.SaveChanges() +20
       TabletsDAL.ArticleDAL.UpdateArticleByID(tblArticle article) +455
       Tablets.AdminPanel.Article_Manage.GVArticles_RowCommand(Object sender, GridViewCommandEventArgs e) +162
       System.Web.UI.WebControls.GridView.OnRowCommand(GridViewCommandEventArgs e) +111
       System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +73
       System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +89
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +88
       System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
       System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +121
       System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +180
       System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724
    Thursday, October 23, 2014 3:44 AM

Answers

  • User1918509225 posted

    Hi Fahad-malik,

    For you issue ,I suggest that you add try/catch block to get the exact error message for specific entity .

    Maybe there is some validation error on your entity while save into database.

    Please try code like below:

     try
            {
    	        db.Entity.Add(entity);
    	        db.SaveChanges();
            }
            catch (DbEntityValidationException dbEx)
            {
    		    foreach (var validationErrors in dbEx.EntityValidationErrors)
    		    {
    		        foreach (var validationError in validationErrors.ValidationErrors)
    		        {
    		            System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
    		        }
    		    }
            }
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 23, 2014 10:36 PM