Q:

Entity Framework table constraints

I want to store such object inside the database
public class Account
{
    [Key]
    public int Id { get; set; }

    [Index(IsUnique = true), Required]
    public string UserName { get; set; }

    [Required]
    public string Password { get; set; }

    [Required]
    public string Email { get; set; }
}

Is any way to say to database that property Email must have appropriate form? So that if i want to add account
var account = new Account
{
     UserName = "X",
     Password = "X",
     Email = "NotValidEmail"
}

database will not accept that object.

A:

Add this over Email property,
 [EmailAddress(ErrorMessage = "Invalid Mail Address")]

hope helps,

