2
우리는 구매 주문서와 관련된 복잡한 유형 CreditCardTransaction
을 사용했습니다. 그것은 정말로 그것이 자신의 실체 일 것임에 틀림없지 만, 나는 지금 이것을 고치려고 노력하고 있습니다.데이터를 잃지 않고 복잡한 유형을 엔티티로 변환
방법이에서 마이그레이션을 작성합니다
[ComplexType()]
public class CreditCardTransaction
{
public String SomeTransactionData { get; set; }
}
이 엔티티로 :
public class CreditCardTransaction
{
public int Id { get; set; }
public String SomeTransactionData { get; set; }
}
이 나를 위해 생성되는 것입니다. 원본 테이블의 데이터를 다른 테이블로 쉽게 옮길 수 있습니까?
public partial class test : DbMigration
{
public override void Up()
{
CreateTable(
"CreditCardTransactions",
c => new
{
Id = c.Int(nullable: false, identity: true),
SomeTransactionData = c.String()
})
.PrimaryKey(t => t.Id);
AddColumn("PurchaseOrder", "Transaction_Id", c => c.Int());
AddForeignKey("PurchaseOrder", "Transaction_Id", "CreditCardTransactions", "Id");
CreateIndex("PurchaseOrders", "Transaction_Id");
DropColumn("PurchaseOrders", "Transaction_SomeTransactionData");
}
// Down() snipped
}
네, 그게 유일한 방법 인 것처럼 보입니다. 끝난! :) –