Note that there are some explanatory texts on larger screens.

plurals
  1. PONot sure how DbContext is creating SQL query to wrong table
    primarykey
    data
    text
    <p>I am new to Entity Framework but im trying to model my code after some examples I have found online. I thought I had it set up the way I wanted but the Query that is created is pointing to the the wrong, non-existant table. I am wondering where it got the table name because it is wrong and I am not seeing any where in any of the project files that this wrong table name was specified. Here is the query that was generated and I got from debugging:</p> <pre><code>{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]} </code></pre> <p>ComputerInventories should be ComputerInventory.</p> <p>Here is my data model</p> <pre><code>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&lt;ComputerInventory&gt; ComputerInventory { get; set; } public AssetDBContext() : base("Name=&lt;name&gt;") { } } </code></pre> <p>Here here is where the I am trying to get the list from the query</p> <pre><code>public ViewResult Index() { return View(db.ComputerInventory.ToList()); } </code></pre> <p>I am completely lost as to where it is getting the ComputerInventories value for the table name.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload