0
我有一個SqLite數據庫有類別表。分類表有3列,ID:INT,名稱:varchar和對象ID:整數無法獲得記錄與實體框架
我寫實體此表:
class Category
{
public int Id { get; set; }
public string Name { get; set; }
public int ObjectId{ get; set; }
}
,我也有一個背景:
class DEContext: DbContext
{
public DbSet<Category> Categories { get; set; }
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Conventions
.Remove<PluralizingTableNameConvention>();
}
}
現在,當我試圖讓與context.Categories類我收到錯誤:
InnerException {"SQL logic error or missing database\r\nno such column: Extent1.Object_Id"} System.Exception {System.Data.SQLite.SQLiteException}
查詢看起來像:
SELECT
[Extent1].[Id] AS [Id],
[Extent1].[Name] AS [Name],
[Extent1].[ObjectId] AS [ObjectId],
[Extent1].[Object_Id] AS [Object_Id]
FROM [Category] AS [Extent1]} System.Data.Entity.DbSet<Category>
我不知道Object_Id來自哪裏。我在db中沒有這樣的列,並且在整個項目中我不使用這樣的名稱。