7
的專欄中,我有兩個的entites:實體框架(CTP5,Fluent API)。重命名導航屬性
public class Address
{
public int Id { get; set; }
public string FirstName { get; set;
public string LastName { get; set; }
}
public partial class Customer
{
public int Id { get; set; }
public string Email { get; set; }
public string Username { get; set; }
public virtual Address BillingAddress { get; set; }
public virtual Address ShippingAddress { get; set; }
}
下面是映射類:
public partial class AddressMap : EntityTypeConfiguration<Address>
{
public AddressMap()
{
this.ToTable("Addresses");
this.HasKey(a => a.Id);
}
}
public partial class CustomerMap : EntityTypeConfiguration<Customer>
{
public CustomerMap()
{
this.ToTable("Customer");
this.HasKey(c => c.Id);
this.HasOptional<Address>(c => c.BillingAddress);
this.HasOptional<Address>(c => c.ShippingAddress);
}
}
當生成的數據庫,我的「客戶」表中有「BillingAddress」和'兩列ShippingAddress'屬性。他們的名字是'AddressId'和'AddressId1'。 問題:如何將它們重命名爲'BillingAddressId'和'ShippingAddressId'?
莫爾塔扎,再次感謝。 – 2011-01-12 08:13:48