Unable to update database to match the current model!
2017-11-10 21:48
411 查看
PM> enable-migrations Checking if the context targets an existing database... Code First Migrations enabled for project BTCheck.
PM> add-migration init Scaffolding migration 'init'. The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running 'Add-Migration init' again.
PM> update-database Specify the '-Verbose' flag to view the SQL statements being applied to the target database. No pending explicit migrations. Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration. You can use the Add-Migration command to write the pending model changes to a code-based migration.
按照正常的codefirst的执行顺序,代码也没有问题,但就是无法更新到数据库。
原因在于在更新数据库之前没有生成解决方案,只要build一下再次update-database一下就可以了。
PM> update-database
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Applying explicit migrations: [201711101328231_init].
Applying explicit migration: 201711101328231_init.
Running Seed method.
相关文章推荐
- PD Update Model from database, Unable to list the users.
- Issue: Server principal is not able to access the database under the current security context
- The server principal "sa" is not able to access the database "xxxx" under the current security context
- 配置hive元数据库mysql时候出现 Unable to find the JDBC database jar on host : master
- GENERAL ERROR: The user is unable to connect to the Oracle database
- 错误解决:Unable to add module to the current project as it is not of package
- "Failed to update database "c:\inetpub\wwwroot\WebSite1\App_Data\ASPNETDB.MDF" because the database is read-only."的解决办法
- 执行 maven 命令 报错Unable to add module to the current project as it is not of packaging type 'pom'
- eclipse ERROR: Unable to add module to the current project as it is not of ...
- unable to find the sources of your current Linux kernel.
- UserWarning: Update your `Model` call to the Keras 2 API: `Model(outputs=Tensor("lo..., inputs=[<tf.
- Unable to add module to the current project as it is not of packaging type 'pom' 问题解决
- Unable to create any keyboard shortcuts after the iOS 6.1.3 update on iPad.
- Unable to add module to the current project as it is not of packaging type 'pom'
- 对象的当前状态使该操作无效 or SPListItem Update Operation is not valid due to the current state of the object
- solution:Failed to update database "XXX.MDF" because the database is read-only.
- 在PowerDesigner12 逆向工程DataBase SQl时出现:unable to list the tables 信息
- CDH 5.7.0 Hive使用Mysql作为元数据库,报unable to find the jdbc database jar on host
- VirtualBox安装VBoxLinuxAdditions错误:unable to find the sources of your current linux kernel
- The connection pool for database '/data/data/....db' has been unable to grant a connection to thread