1

Hi my mvc class include Data Annotation [Index] but After updating the visual studio, my [Index] Data Annotation not working and not working unique.

How i am fixed that code ?

public class MaterialSupplier
{
    public int MaterialSupplierID { get; set; }

    [Index("IX_MaterialSupplier", 1, IsUnique = true)]
    public int MaterialID { get; set; }

    [Index("IX_MaterialSupplier", 2, IsUnique = true)]
    public int SupplierID { get; set; }

    [Required]
    public decimal UnitPrice { get; set; }

    [DefaultValue(0)]
    public bool IsDeleted { get; set; }

    public virtual Material Material { get; set; }
    public virtual Supplier Supplier { get; set; }
    public virtual ICollection<MaterialOrderDetail> MaterialOrderDetails { get; set; }
}
  • Yes i have a database but after updating the visual studio,[Index] not work –  Sep 11 '15 at 23:09
  • See if the answer by Kryptos here helps. Seems to be issues defining a composite index on FK columns. http://stackoverflow.com/questions/18889218/unique-key-constraints-for-multiple-columns-in-entity-framework – Steve Greene Sep 13 '15 at 15:11

0 Answers0