none
Index already exists error in EF 4.3 Code First with Data Annotations RRS feed

  • General discussion

  • I'm trying to create a billing database with Entity Framework 4.3 using Code First with Data Annotations, and I'm getting an error every time I try to create my database. Here are the objects that I'm dealing with:

    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int ClientID { get; set; }

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

    [Required]
    public bool IsActive { get; set; }

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

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

       public virtual List<PropertyBase> Communities { get; set; }

          }

    public class PropertyBase
    {

    [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int PropertyID { get; set; }

    [ForeignKey("Client")]

    public int ClientID { get; set; }

    [Required, EnumDataType(typeof(BillingFrequency))]
    public BillingFrequency PropertyBillingFrequency { get; set; }

    [Required]
    public bool IsActive { get; set; }

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

    public string PropertyStreet { get; set; }

    public string PropertyCity { get; set; }

    public string PropertyState { get; set; }

    public int PropertyZipCode { get; set; }

    public virtual ClientBase Client { get; set; }

    }

    I keep getting an error saying that there is already an index on Property for the ClientID. Does anyone know how to fix this?

    BTW, it's also on Stacknbsp;http://stackoverflow.com/questions/10438219/index-already-exists-error-in-ef-4-3-code-first-with-data-annotations

    Thanks for all of your help!

    Thursday, May 3, 2012 8:05 PM

All replies