简体   繁体   中英

Entity Framework does not create a new migration: database name is invalid

We are using Entity Framework migrations in a project. So far we have added several migrations with no problem but it stopped working. Now whenever we try to add a migration EF shows an error with the following message:

The database name 'my-table-name' is invalid. Database names must be of the form [schema_name.]object_name.

Furthermore if we execute the update-database command, EF tells us that the model does not match the database. But the model has not been changed (we want to create an "empty" migration).

We have tried to go back to previous migrations, start from scratch but we always get the same result. Oddly enough sometimes the invalid table varies. We don't think is related to any pluralization issues on the context configuration.

Any help will be greatly appreciated.

  • Entity-Framework version: 6.1.3-40302
  • Database: SQL Server 11.0.5058.0

Finally the solution was quite straight forward, just run the Add-Migration command along with the IgnoreChanges parameter.

This did not yeld any error and created a blank migration. Then, we updated the database without adding anything to the blank migration, deleted the files attached to it and we were able to create standard migrations again.

Why EF could not add new migrations before and the origin of the error message is still a mistery to us.

Thank you everyone for your help!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM