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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:41:37+00:00 2026-06-14T00:41:37+00:00

I have an Entity Framework 4.1 model that supports multiple ASP.NET MVC web applications.

  • 0

I have an Entity Framework 4.1 model that supports multiple ASP.NET MVC web applications. I use DataAnnotations to define and localize label text and validation rules and error messages.

For some applications, I need the label text for certain fields to differ from the standard, model-defined text. This is easy to achieve for the labels themselves: I retrieve the text I need from a local resource file, associated with the view. However, the label text is also used in validation error messages such as “{fieldname} must have a maximum length of 50 characters”.

What is the best way to alter the validation messages without changing the Annotations on the model classes?

  • 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-14T00:41:39+00:00Added an answer on June 14, 2026 at 12:41 am

    You have coupled your validation to your entity models. The way to avoid this is to create view models from your entities and put the validation on to those.

    Example: If you have the Entity…

    public class Product
    {
        public string Name {get; set;}
    }
    

    you could create two different view models:

    public class ProductPageViewModel1
    {
        [Required]
        public string Name {get; set;}
    }
    
    public class ProductPageViewModel2
    {
        [DisplayName("Foo")]
        public string Name {get; set;}
    

    }

    Map the entity to the view model and use these in your views.

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

Sidebar

Related Questions

I'm building an ASP.NET MVC site using the ADO.NET Entity Framework. I have an
I have an ADO.NET Data Service that exposes an Entity Framework data model (.edmx).
I have a simple ADO.NET Entity Framework 4.0 model (edmx) which defines database tables
I have several Entity Framework Code First DbContext objects that use a custom Initializer.
I have an object defined by my entity framework model that has navigation properties,
I have an Entity Framework model that has 3 tables (each with indentity primary
I have an Entity Framework model that was generated by the Visual Studio 2008
I currently have an Entity Framework model that collects data from a legacy database
I have put together a small ASP.NET MVC 2 site that does some very
I have an Entity Framework model that contains the tables apsnet_Users aspnet_Memberships I want

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.