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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:35:52+00:00 2026-06-12T09:35:52+00:00

I used Database-First to generate a model class (EDMX file), and I want to

  • 0

I used Database-First to generate a model class (EDMX file), and I want to validate using “MetadataType”. I read solutions here but they didn’t work for me.

Here is my code:

[MetadataType(typeof(MovieEntitiesMetaData))]
public partial class MovieEntities
{        
}

public class MovieEntitiesMetaData
{
    [DisplayFormat(DataFormatString = "{0:c}")]
    public Nullable<global::System.Decimal> PRICE { get; set; }
}

Is there anything missing here, or why did my solution did not work?

  • 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-12T09:35:54+00:00Added an answer on June 12, 2026 at 9:35 am

    Create a new file called MoviePartial.cs and place the following code inside it:

    [MetadataType(typeof(MovieMetaData))]
    public partial class Movie
    {    
        internal sealed class MovieMetaData
        {
            [DisplayFormat(DataFormatString = "{0:F2}", ApplyFormatInEditMode = true)]
            [Required(ErrorMessage = "Price is required")]
            public decimal? PRICE { get; set; }
        }
    }
    

    You also need to pass the Movie type to the view so that the data annotations can be wired up. If you have a custom view model the data annotations won’t get in action.

    In the Create/Edit view you must have:

    @Html.EditorFor(m => m.PRICE)
    

    In the Details view you must have:

    @Html.DisplayFor(m => m.PRICE)
    

    For more on this, just follow this nice step by step tutorial:

    Validation with the Data Annotation Validators (C#)

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

Sidebar

Related Questions

I've been using RandomStringUtils to generate random IDs to be used as database keys:
I used SQLMetal to generate a code file representing my database, and i can't
I have used RESTful techniques to generate a model (in fact, I am using
I am working on an database class based on pdo, the database used is
LogIn class where my database is used: package edu.flying.panda.taskmanager; import android.util.Log; import android.view.View; import
i had sideshow ajax and i want it get images form database i used
I am developing an EF - MVC 3 application. I have used model first
I want to write a java code to read the input XML file and
I am used to using Oracle Designer by creating database object definitions, then creating
I've created a business layer with a database model to be used in an

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.