Orchard 1.6 を使用
public virtual int? BusinessCategory_Id { get; set; }
して、'CustomerPartRecord' テーブルに追加しました。そして追加
public int? BusinessCategory_Id
{
get { return Record.BusinessCategory_Id; }
set { Record.BusinessCategory_Id = value; }
}
私の「CustomerPart」テーブルに。次に、移行ファイルに次を追加しました。
public int UpdateFrom26()
{
SchemaBuilder.CreateForeignKey("ProductCategoryRecord_CustomerPartRecord", "CustomerPartRecord", new[] { "BusinessCategory_Id" }, "ProductCategoryRecord", new[] { "Id" });
return 27;
}
したがって、これは「ProductCategoryRecord」テーブルから「Id」を取得し、「CustomerPartRecord」テーブルに「BusinessCategory_Id」と呼ばれる FK として保存する必要があります。
以前に他の値でこれを試してみましたが、うまくいきましたが、今回はエラーが発生しています:Foreign key 'Umacs_ProductCategoryRecord_CustomerPartRecord' references invalid column 'BusinessCategory_Id' in referencing table 'Umacs_UMACS_Bradmount_CustomerPartRecord'.
Could not create constraint. See previous errors.
ログファイルでそれは私に言っています
2013-07-24 17:38:49,716 [28] Orchard.Data.Migration.DataMigrationManager - An unexpected error orccured while applying migration on UMACS.Bradmount from version 26
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: Foreign key 'Umacs_ProductCategoryRecord_CustomerPartRecord' references invalid column 'BusinessCategory_Id' in referencing table 'Umacs_UMACS_Bradmount_CustomerPartRecord'.
Could not create constraint. See previous errors.
また、キャッシュファイルを削除してdevlを再起動してみました。サーバ。
何か案は?