SqlException: Invalid object name 'Movie' SqlException: Invalid object name 'Movie' sqlite sqlite

SqlException: Invalid object name 'Movie'


I had a similar error even though all the tables were properly created. It turned out that my connection string was wrong.


Since the error is SqlException: Invalid object name 'Movie', that means the table named 'Movie' has not created or the Database you are referring has not created.

To see if the Database or table 'Movie' has created, open SQL Server Object Explorer and check the Database name is the same as in appsettings.json. If the Database or table has not created, you may need a migration.

To migrate, open Tools-> NuGet Package Manager-> Package Manager Console and hit the following commands:

  1. Add-Migration MigrationName
  2. Update-Database

Then check SQL Server Object Explorer again or build and run your project.


Do you have a Movies or Movie table in your database?

Since you say that dotnet ef migrations add --context MvcMovie2Context fails, leads me to believe that your model has not been reflected in the database schema. Also, as far as I know, you need to provide a migration name, which is probably why you are receiving the error.

Please try running the following commands.

1.dotnet ef migrations add "AddedMovieEntity" --context MvcMovie2Context

2.dotnet ef database update --context MvcMovie2Context

Hopefully this time step 1 will run successfully, from there you should see a migration file that includes the schema for the Movie entities. After step 2, you should see the respective table in your database.