我有以下课程:
public abstract class BaseAttachment
{
public Guid BaseAttachmentId { get; set; }
public string FileName { get; set; }
public string FileExtension { get; set; }
public string FileSize { get; set; }
public Folder Folder { get; set; }
public Guid? FolderId { get; set; }
public byte[] RowVersion { get; set; }
}
我在Table下面并继承BaseAttachment
:
public class ProductGallery : BaseAttachment
{
public ProductHeader ProductHeader { get; set; }
public Guid? ProductHeaderId { get; set; }
}
和此:
public class Attachment:BaseAttachment
{
}
运行项目和创建数据库时我有下表:
BaseAttachment,ProductCategory
而不是一个表(BaseAttachment
)。
为什么?
答案 0 :(得分:0)
我是ProductCategoryConfig
的配置类,下面是Set TableName:
public class ProductGalleryConfig:EntityTypeConfiguration<ProductGallery>
{
public ProductGalleryConfig()
{
ToTable("ProductGallery");
Property(row => row.Code).HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);
Property(row => row.RowVersion).IsRowVersion();
HasRequired(row => row.ProductHeader).WithMany(row => row.Galleries).HasForeignKey(row => row.ProductHeaderId).WillCascadeOnDelete(false);
}
}
和评论下面的Line及其修复。
// ToTable("ProductGallery");