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

  • Home
  • SEARCH
  • 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 8552941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:32:15+00:00 2026-06-11T14:32:15+00:00

If I have defined next in map file (1-to-Many relationship between Units and Machines):

  • 0

If I have defined next in map file (1-to-Many relationship between Units and Machines):

this.HasRequired(t => t.Unit)
    .WithMany(t => t.Machines)
    .HasForeignKey(d => d.UnitId);

When I add new entity, Machine.UnitOfMeasurement = null, sp why does DbContext return no validation problem when calling GetValidationErrors and what can I do to detect them. If I allow EF to try to update, it will return meaningless message to user, like foreign key reference error, while I can extract meaningful information to user from DbEntityValidationResult (ex property name that issued a validation error).

I am using IDataErrorInfo for validation rules, not Attributes.

  • 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-11T14:32:16+00:00Added an answer on June 11, 2026 at 2:32 pm

    EF validation does not validate navigation properties. The reason for this is that a navigation property may be null not because a related entity does not exist but because lazy loading is enabled and the related entity is just not loaded. Also, even if the navigation property is null you might have set the corresponding foreign key property which basically means that relation exists but the navigation property has not been updated yet. Also note that forcing loading related entities would mean that validation brings your entire database to memory (after loading related entities they will be validated what would result in loading related entities of newly loaded entities and so on) – you don’t want this to happen (EF actually turns off lazy loading during validation to prevent from this).
    EF Validation does not support IDataErrorInfo – only validation attributes and IValidatableObject.

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

Sidebar

Related Questions

I have defined a vector like this in the header file class entry {
I have defined a few constants like this: define(TITLE_2,Yahoo); define(TITLE_3,Google); Next, I want to
I need to call a method I have defined as: -(IBAction)next:(id)sender{ ... } I
I have defined a rectangle drawable like this: <shape xmlns:android=http://schemas.android.com/apk/res/android android:shape=rectangle> <corners android:radius=4dip/> <solid
I have defined a for loop as follows which scans through a file made
My professor defined this in the .h file void list_map(INTLIST* list, void (*f)(void *));
I have a globally defined ArrayList as ArrayList<Map<String, String>> mContactList; . Now, in one
I have next code: #include <iostream> #include <algorithm> #include <map> #include <iterator> //namespace std
i have defined a method like this: private String getRadndomNumber(int min, int max) {
I have the next scenario: I define an int[][] variable in my main class.

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.