I am using Entity Framework with a code-first approach for ASP.NET MVC 5 with a SQL Server 2014 database. The application is already available in a production environment. Now I am looking to add a new table to the existing database.
Here are the steps that I have followed :
Added the Model class Customer.cs
within the Models
folder in the Data
project
Updated the context class SampleDBContext
class with the new model
public class SampleDBContext : DbContext
{
public IDbSet<Customer> Customers{ get; set; }
}
Created a SQL script corresponding to the above model class and executed it against the database
Now on running the application, I get an error which says
Invalid object name 'dbo.Customers'
Can anyone help me here by providing their guidance to fix this issue?
This is an SQL error. The database being accessed does not have an SQL object (such as a table, in this case).
You need to create a [dbo].[Customers]
table. For some reason, your 3rd step did not properly create a [dbo].[Customers]
table on the database you are accessing.