Database is not getting created at first time

asp.net-mvc database-migration entity-framework-6

Question

How can the database be rebuilt using EF6?

I tried the two posts below, but I don't know why it's not working or why I keep receiving the same issue.

  1. How can I create an EF6 database without using update-database that has migrations enabled?
  2. Although migrations are enabled for the context, the database is either empty or lacks any mapped tables.

My sample is already available on the web server. I'm using the DBMS Sql Server Express 2012.

My program was functioning properly when I constructed it and published it on a web server. The database was automatically built. I then made some modifications toApplicationDBContext and included a few propertiesIdentityModes(ApplicationUser) . Then, I migrated the database on my IIS Express locally, and everything was running smoothly. Then I attempted to publish my sample on the web server once more, but this time an error was displayed.

Migrations is enabled for context 'ApplicationDbContext' but the database does 
not exist or contains no mapped tables. Use Migrations to create the database 
and its tables, for example by running the 'Update-Database' command from the 
Package Manager Console.

I tried again after deleting the database on the web server. but I'm still having the same problem. There is currently no table in the empty database.

Database on user registration is being created by the application.

Additionally, I read this and attempted to contact post.dbContext.Database.Initialize(true); and ((IObjectContextAdapter)myContext).ObjectContext.CreateDatabase() way, yet it is still ineffective.

1
3
5/23/2017 10:34:02 AM

Accepted Answer

ZZZ_tmp
3
9/22/2014 6:46:07 PM

Popular Answer

By the way, Chris Pratt is right.

I downloaded a project that required me to just execute "Update-Database."

The quick screenshots are shown below.

enter image description here

then, in Visual Studio's bottom corner

 PM> Update-Database

DONE



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow