1
データアノテーションのコードファーストを使用して、Entity Framework 4.3で請求データベースを作成しようとしています。データベースを作成しようとするたびにエラーが発生します。 。ここで私が扱ってるオブジェクトです:私は流暢でこの質問へのソリューションを見てきましたEF 4.3のインデックスが既に存在します。コードデータアノテーションのコード
The operation failed because an index or statistics with name 'IX_ClientID' already exists on table 'Property'.
:どんなに私がやろう何
public class ClientBase
{
[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; }
}
が、私はいつもこのエラーが出ますAPIを使用していますが、Data Annotationsの1つが見つかりませんでした。
これを修正する方法はありますか?
EDIT:それを修正
public DbSet<ClientBase> ClientBases { get; set; }
public DbSet<PropertyBase> PropertyBases { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<PluralizingTableNameConvention>();
base.OnModelCreating(modelBuilder);
}
それはすべて私のために働く。私はテーブル* 'プロパティ' *がこの構成でどこから来ているのか分かりません。 – tzerb
Yikes!私は[Table( "Property")]をPropertyBaseクラスに置くのを忘れていました。 – IronMan84
インデックスを作成したSQLサーバー上でトリガが実行されていますか?私はそれが(最初のものさえ)どこから来るのか分かりません。 – tzerb