I am using asp.net mvc and EF for its DB. I use the "generate from database" tool. Everything is ok but the validation. I want the validations match the check constraints I have added to db before.
This is my db table creator query :
use MagicContact
create table Contacts
(
ID int primary key not null identity,
name nvarchar(50),
last_name nvarchar(50),
mobile nvarchar(11),
country int foreign key references Country(ID),
constraint CX_Contacts_mobile check(mobile like '[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]' or mobile like '0[1-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]')
)
The generated model is as below and it hasn't my constraints :
namespace MVCMajicContacts
{
using System;
using System.Collections.Generic;
public partial class Contact
{
public int ID { get; set; }
public string name { get; set; }
public string last_name { get; set; }
public string mobile { get; set; }
public int country { get; set; }
public virtual Country Country1 { get; set; }
}
}
And I couldn't find any good way.