我有一个实体,其中包含许多不同的文档,与我的数据库中的任何实体都存在未知关系.
public class Document : BaseEntity
{
public string Filename { get; set; }
public string MIMEType { get; set; }
public int? Length { get; set; }
public byte[] Content { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
而codefirst-mapping是:
public DocumentConfiguration()
{
Property(x => x.Filename).HasMaxLength(300).IsRequired();
Property(x => x.MIMEType).HasMaxLength(300).IsRequired();
Property(x => x.Length).IsOptional();
Property(x => x.Content).IsOptional().HasColumnType("varbinary(max)");
ToTable("Document");
}
Run Code Online (Sandbox Code Playgroud)
现在我希望在我的addressentity中有一个与document-table的可选关系,如下所示:
public class Address : BaseEntity
{
public string Name1 { get; set; }
public string Name2 { get; set; }
public string Additional { get; …Run Code Online (Sandbox Code Playgroud)