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 9273723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:10:52+00:00 2026-06-18T16:10:52+00:00

At work we are looking to move to an ORM (still using an access

  • 0

At work we are looking to move to an ORM (still using an access database with ADO!) I started building with entity framework and everything was going smoothly until I separated it off into it’s own .dll (so we could have the website/crm/production/barcoding systems all using the same database logic).

The issue comes with handling the DbEntityValidationExceptions, my initial test code (which worked)

public override int SaveChanges(System.Data.Objects.SaveOptions options)
        {
            try{return base.SaveChanges(options);}
            catch (DbEntityValidationException dbEx)
            {
                foreach (var validationErrors in dbEx.EntityValidationErrors)
                {
                    foreach (var validationError in validationErrors.ValidationErrors)
                    {
                        Trace.TraceInformation("Class: {0}, Property: {1}, Error: {2}",
                            validationErrors.Entry.Entity.GetType().FullName,
                            validationError.PropertyName,
                            validationError.ErrorMessage);
                    }
                }
                //handle here
                throw;
            } 
        }

but this doesn’t get caught now and i’m left handling a generic threadException. Is there any way to access the original data (cast the threadException?) or is there a different approach I should take. I think I just need a push in the right direction and I can figure something out.

Regards, Pete

UPDATE:

Hmm bit of an issue calling the GetValidationErrors. I notice that my database Context has the baseClass of ObjectContext and not DbContext (So I can’t call the ValidateEntity). I’m using Entity Framework 5 with default code generation enabled – using a database first approach if that helps.

  • 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-18T16:10:53+00:00Added an answer on June 18, 2026 at 4:10 pm

    check for validation errors before calling SaveChanges. Something like…

    var errors = context.GetValidationErrors();
    if(errors.Any())
    {
       //handle validation errors
    }
    else
    {
        context.SaveChanges();
    }
    

    from memory, so the exact syntax may not be correct.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I work at a small ecommerce site and we're looking to move to all
I’m looking to move over to using git to make my EE development a
I've recently been doing some DirectX 10 work and I'm looking to move to
We are looking to move from manual scripts to the RedGate database source control
The company I work for is currently looking to move from traditional waterfall into
The company I work for is looking for a reporting solution with the following
The company I work for is looking to implement a caching solution. We have
I work with MEF and I am looking how to change the url of
Looking for a proven to work algorithm for production. Did see this example but
Just looking on resources that break down how frames per second work. I know

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.