I use Entity Framework
for data access. There is a context class:
public class Context : DbContext { public string cs; public Context(string connection_string) { Database.Connection.ConnectionString = connection_string; cs = connection_string; } public DbSet<Customers> cust { get; set; } public DbSet<Orders> ord { get; set; } public DbSet<Cars_In_Stock_Table> cars { get; set; } }
Trying to get data:
public IEnumerable<Cars_In_Stock_Table> GetAllCars() { return context.cars; }
Visual Studio regarding context.cars
gives:
Implicit conversion ... DbSet <...> to ... IEnumerable <...> impossible
Saw examples where this approach works. You can use ToList()
, but I would like to understand the reason. Could this be related to the Entity Framework
version?