I am new to the Entity Framework, but I am trying to model my code after some examples that I found on the Internet. I thought I configured it the way I wanted, but the query created indicates an invalid, non-existent table. I am wondering where the table name comes from, because it is incorrect, and I do not see anywhere in any project file that this incorrect table name was indicated. Here is the request that was generated and I received from debugging:
{SELECT [Extent1].[AssetTag] AS [AssetTag], [Extent1].[Location] AS [Location], [Extent1].[PoolType] AS [PoolType], [Extent1].[InventoryStatus] AS [InventoryStatus], [Extent1].[InventoryType] AS [InventoryType], [Extent1].[Comments] AS [Comments] FROM [dbo].[ComputerInventories] AS [Extent1]}
ComputerInventories must be ComputerInventory.
Here is my data model
public class ComputerInventory { [Key] public String AssetTag {get; set;} public String Location { get; set; } public String PoolType { get; set; } //public String ReasonInProgram { get; set; } public String InventoryStatus { get; set; } public String InventoryType { get; set; } [StringLength(500)] public String Comments { get; set; } //public String Clock { get; set; } } public class AssetDBContext : DbContext { public DbSet<ComputerInventory> ComputerInventory { get; set; } public AssetDBContext() : base("Name=<name>") { } }
Here I am trying to get a list from a query
public ViewResult Index() { return View(db.ComputerInventory.ToList()); }
I completely lost information about where it gets the ComputerInventories value for the table name.
Dford source share