Good day! The second day I can not understand why EF does not pull values ​​from the table ...

Table creation script:

CREATE TABLE "Category" ( `Id` INTEGER NOT NULL, `Name` TEXT NOT NULL, `MinPercent` REAL NOT NULL, `MaxPercent` REAL NOT NULL, `HasEmployee` INTEGER NOT NULL DEFAULT 0, `Surcharge` REAL NOT NULL DEFAULT 0, `SalaryRate` REAL NOT NULL, `CurrencyId` INTEGER NOT NULL, PRIMARY KEY(`Id`), FOREIGN KEY(`CurrencyId`) REFERENCES `Currency`(`Id`) ) 

Model Class Code:

 [Table("Category")] public class Category { [Key] public Int32 Id { get; set; } public String Name { get; set; } public Single MinPercent { get; set; } public Single MaxPercent { get; set; } public Boolean HasEmployee { get; set; } public Single Surcharge { get; set; } public Single SalaryRate { get; set; } public Int32 CurrencyId { get; set; } } 

Context DB Code:

 public DbSet<Category> Category { get; set; } 

I select the data as follows:

 public IEnumerable<Category> GetCategories { get { return _dbContext.Category; } } 

And all this selects 0 entries, although there are entries in the table. Who faced or who has ideas how to overcome it, tell me! Thank!

  • 2
    Show how you request records from the database. This is the main, not the database creation script. And you have EF 6th or Core? - Bulson
  • public IEnumerable <Category> GetCategories {get {return _dbContext.Category; }} - Evgeny Smelov
  • return _dbContext.Category will not return anything, you need to make a request using LINQ. - Bulson
  • @Bulson, why do others return? - Evgeny Smelov
  • First, no one directly connects requests to properties. Secondly, read the first lessons - Bulson

0