实体注释属性不起作用
本文关键字:不起作用 属性 注释 实体 | 更新日期: 2023-09-27 18:04:11
这是我的实体:
[Table( Name = "PdfMeta" )]
public class Meta
{
[Key()]
public int Id { get; set; }
[Column(Name = "TotalPages")]
public int TotalPages { get; set; }
[Column(Name = "PdfPath")]
public string PdfUri { get; set; }
[Column(Name = "ImagePath")]
public string ImageUri { get; set; }
[Column(Name = "SplittedPdfPath")]
public string SplittedFolderUri { get; set; }
}
下面是上下文中的代码:
public DbSet<Meta> PdfMeta { get; set; }
为什么用ImageUri, PdfUri…创建新的表(Metas)列?我知道这是按照惯例做的,但是我已经明确指定了表和列。
ColumnAttribute
的Name
属性只定义了getter。在构造函数中传递列名:
[Table("PdfMeta")]
public class Meta
{
[Key]
public int Id { get; set; }
[Column("TotalPages")]
public int TotalPages { get; set; }
[Column("PdfPath")]
public string PdfUri { get; set; }
[Column("ImagePath")]
public string ImageUri { get; set; }
[Column("SplittedPdfPath")]
public string SplittedFolderUri { get; set; }
}
BTW ColumnAttribute
在EntityFramework.dll中定义。看起来您已经从System.Data.Linq.dll
ColumnAttribute