0

I want to create a class where the ID value can start from 8000 so that it wont conflict with any other IDs from other tables/models. Here's my model

public class Employee
{

    [Required]
    [Range(8000,10000)]        
    public long Id { get; set; }

    [Required]
    [DataType(DataType.Text)]
    [Display(Name = "First Name")]
    public string FirstName { get; set; }

    [Required]
    [DataType(DataType.Text)]
    [Display(Name = "Last Name")]
    public string LastName { get; set; }

    [Required]
    [DataType(DataType.PhoneNumber)]
    [Display(Name = "Phone ")]
    public string PhoneNumber { get; set; }

    public virtual Address Address { get; set; }        

    [DataType(DataType.EmailAddress)]
    [Display(Name = "E-mail")]
    public string Email { get; set; }

    [DataType(DataType.Date)]        
    [Display(Name = "Date of Birth", Prompt="MM/DD/YYYY")]                
    public DateTime dateOfBirth { get; set; }

    public virtual IEnumerable<Availability> availability {get;set;} 
}
Fpanico
  • 49
  • 1
  • 8
  • have you tried [this](http://stackoverflow.com/questions/7256753/min-max-value-validators-in-asp-net-mvc) – Amol Mar 11 '13 at 03:22
  • apparently the range is only useful for validation, I thought I could use it for auto-increment. – Fpanico Mar 11 '13 at 03:26

1 Answers1

0

Model attributes don't set values - they validate them. If you are concerned with Primary Key Identity inserts, then change your key from an integer to a GUID. Setting and arbitrary 8000 limit will seriously limit scalability and protability in the future.

viperguynaz
  • 12,044
  • 4
  • 30
  • 41