Nop.Data.Mapping のクラスは、テーブルとプロパティを定義します。
public partial class CustomerMap : EntityTypeConfiguration<Customer>
{
public CustomerMap()
{
this.ToTable("Customer");
this.HasKey(c => c.Id);
this.Property(u => u.Username).HasMaxLength(1000);
this.Property(u => u.Email).HasMaxLength(1000);
this.Property(u => u.Password);
this.Property(c => c.AdminComment).IsMaxLength();
this.Property(c => c.CheckoutAttributes).IsMaxLength();
this.Property(c => c.GiftCardCouponCodes).IsMaxLength();
this.Ignore(u => u.PasswordFormat);
this.Ignore(c => c.TaxDisplayType);
this.Ignore(c => c.VatNumberStatus);
this.HasOptional(c => c.Language)
.WithMany()
.HasForeignKey(c => c.LanguageId).WillCascadeOnDelete(false);
this.HasOptional(c => c.Currency)
.WithMany()
.HasForeignKey(c => c.CurrencyId).WillCascadeOnDelete(false);
this.HasMany(c => c.CustomerRoles)
.WithMany()
.Map(m => m.ToTable("Customer_CustomerRole_Mapping"));
this.HasMany(c => c.DismissedAttributeNotices)
.WithMany()
.Map(m => m.ToTable("ProductAttribute_DismissedAttributeNotices"));
this.HasMany<Address>(c => c.Addresses)
.WithMany()
.Map(m => m.ToTable("CustomerAddresses"));
this.HasOptional<Address>(c => c.BillingAddress);
this.HasOptional<Address>(c => c.ShippingAddress);
this.HasOptional<Customer>(c => c.SelectedSalesRep);
}
}
Customer は Nop.Core.Domain.Customers.Customer.cs で定義されます。そのすべてのプロパティがテーブルにマップされます。ここで追加する必要があるのは、使用するテーブル、無視するプロパティ、関係、およびフィールドのプロパティ (文字列の長さまたは精度) だけです。