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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:07:47+00:00 2026-05-24T18:07:47+00:00

I have a user model with two [NotMapped] string properties Password and ConfirmPassword. These

  • 0

I have a user model with two [NotMapped] string properties Password and ConfirmPassword. These are unmapped because I save password as byte array (after salting) so there are two additional properties (mapped) InternalPassword and Salt in user model.

The problem is when I use the user model to change password, entity framework throws DBEntityValidation error stating “The Password property is required.” What I understand here is that EF is trying to validate my model before saving and since Password/ConfirmPassword are not set, it is throwing this error. This raises following questions:

1) If property Password is explicitly annitated as [NotMapped], why is EF validating it during save?
2) IF EF performs validation during save, and the same is also performed during binding (I.E. in the controller action method), does it not hurt performance? (validating twice)
3) What’s the recommended way to resolve this error? (If I explicitly set Password property to dummy value, error is gone.)

Edit: I’ve removed the code since it is lengthy and may be the cause of no answer yet. If somebody wants to have a look, I can append it below.

  • 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-05-24T18:07:49+00:00Added an answer on May 24, 2026 at 6:07 pm

    Automatic validation in EF is somehow strange feature – I don’t like it. You can read this article to find some information how to validate just selected properties but I expect you must trigger that validation manually and turn off global validation by calling:

    context.Configuration.ValidateOnSaveEnabled = false;
    

    Your problem with NonMappedAttribute is interesting. I didn’t go deep into implementation of validation in EFv4.1 but if the implementation is build around the same rules as common validation based on data annotations, it uses only attributes derived from ValidationAttribute – NotMappedAttribute is not derived from ValidationAttribute.

    That is another problem of such implementation – it combines mapping definition and validation but these two features are not the same and should not be implemented by the same API.

    @alun deleted his answer – the valid answer to your question. Your validation belongs to view model dependent on the operation a user is performing. It doesn’t belong to persistence model. Why? Exactly because of your current issue – persistence model can hold only single validation set and every operation in your application must ensure that validation criteria for that set are met = you must ensure that Password and ConfirmPassword are filled even if your current operation doesn’t demand it => problem.

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

Sidebar

Related Questions

Suppose you have two models, User and City, joined by a third model CityPermission:
I have a user model that requires the user to change their password every
I have two models: User MentoringRelationship MentoringRelationship is a join model that has a
I have two models: User and Base. User model: http://pastebin.com/WdLzBkHJ Base model: http://pastebin.com/tQrEUaSu At
I have two types of users: user and editor. I have a User model
I have these models class User(models.Model): user_name = models.CharField() ph_number = models.CharField() class ExamPaper(models.Model):
I have a User model that, in my mind, has two show actions: A
I have two models, User and Discussion User model has_and_belongs_to_many :subscribed_discussions, :class_name => 'Discussion',
I have a User Model(:name, :password, :email), and Event model(:name, :etc) and Interest model
I have a User Model(:name, :password, :email), and Event model(:name, :etc) and Interest model

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.