Object annotation attributes do not work

Here is my essence:

[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; } } 

Here is the code from the context:

  public DbSet<Meta> PdfMeta { get; set; } 

Why is the new table (Metas) created using ImageUri, PdfUri ... columns? I know that this was done by convention, but I clearly indicated the table and columns.

+6
source share
1 answer

Name property of ColumnAttribute has only a qualifier. Instead, enter the column name in the constructor:

 [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 defined in EntityFramework.dll. It looks like you referenced ColumnAttribute from System.Data.Linq.dll

+4
source

All Articles