Search code examples
asp.netasp.net-mvc-3models

What is wrong with my model? [EmailAddress] namespace could not be found?


I installed data annotations MVC3 (I am using MVC3) and my [EmailAddress] data annotation cannot be found. I searched online and I do not understand why it is not referencing.

Here is my model:

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Web.Mvc;
using System.Web.Security;

    namespace Projectx.Models
    {

        public class PreSignUpUser
        {
            [Required]
            [EmailAddress]
            public string Email { get; set; }
        }
    }

Can someone help me out?


Solution

  • Maybe try this:

    [DataType(DataType.EmailAddress)]
    

    in place of

    [EmailAddress]