Reputation: 302
My start-up conditions:
services.AddDbContext<MyDbContext>(options => options.UseSqlServer(connectionString))
;DbContextOptions<MyDbContext> options
constructor;Using all of mentioned I perform (dotenet ef migrations add Initial --project ../MyDALProject
) on an empty model to get an empty Initial Migration. That works fine. Then I run dotenet ef database update --project ../MyDALProject
to apply this Empty Migration to the database. Nevertheless, I get "Database 'TargetDatabase' already exists. Choose a different database name".
BTW.: other projects work with the same Db just as fine.
What can be the problem? How to make it works?
P.S.: other projects' contextes, I have mentioned, are been scaffolded and mapped to some existing tables. After scaffold, migrations and updates work as expected. The problem relys only to this project, which will bring new tables to an existing db.
Upvotes: 0
Views: 955
Reputation: 126
For me, I renamed the database directory which contains the mdf and logs directory. Had to give it back its name to get the migration working.
Still inaccessibility issues.
Upvotes: 0
Reputation: 302
After all, I decided to apply scripts to db manually and then found out, that db was inaccessible... Finally, I restored it and everything ran perfectly.
Upvotes: 1