Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7732861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:50:16+00:00 2026-06-01T06:50:16+00:00

Would be nice if the Entity framework had the ADO.Net equivalent of DataRow.HasErrors. I’m

  • 0

Would be nice if the Entity framework had the ADO.Net equivalent of DataRow.HasErrors.

I’m running into cases where the server returns errors on my save (such as “binary/string data would be truncated, non nullable fields set to null, etc), and there’s no way to tell which entity caused the problem. In ADO.Net this was easier, since after telling the DataAdapter to save the changes I could just go through all datarows and just check the ones that had HasErrors on. Granted this would not pinpoint the field, but would at least tell me which row caused the problem.

I can’t seem to find an Entity equivalent to this. Does anyone know if there is one?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T06:50:18+00:00Added an answer on June 1, 2026 at 6:50 am

    In both of the cases you describe you would get a DbUpdateException thrown when you attempt to save.

    This exception has a property on it called Entries. You can use this property to get hold of the entities that caused the failure. Each entity is a DbEntityEntry object and that has a property that has the real entity plus loads more information about what the error was etc.

    So in the case that you describe just catch the exception and look at the Entries collection to find out the root cause of the problem something like this:

    try
    {
        c.SaveChanges();
    }
    catch (DbUpdateException ex)
    {                   
        IEnumerable<object> myBadEntities = 
            ex.Entries.Select(e => e.Entity);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's the scenario: ASP.NET MVC2 Web Application Entity Framework 4 (Pure POCO's, Custom Data
I would like to use Entity Framework Code first approach with SQLCE4 database. Everything
Sometimes you have a huge entity with numerous fields and it would be nice
I've just ran into an unexpected behaviour for Entity framework entities in use with
I'm trying to determine how best to architect a .NET Entity Framework project to
Yesterday I thought it would be nice to implement my own Trigger in a
I have a C extension module and it would be nice to distribute built
This discussion started over here but I thought it would be nice to have
Just listening to this week's podcast and thought it would be nice to group
I have a ruby on rails application and it would be nice to see

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.