Unable to update database to match the current model!

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.


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果您在安装和配置 Roundcube Webmail 时出现 "DATABASE ERROR: CONNECTION FAILED! Unable to connect to the database! Please contact your server-administrator." 的错误消息,那么可能是以下原因之一: 1. 数据库详细信息不正确 请确保您在 config/config.inc.php 文件中输入了正确的数据库详细信息,包括数据库名称、数据库用户名、数据库密码和数据库主机。您可以使用以下命令检查您的数据库详细信息: ``` sudo nano /var/www/html/roundcube/config/config.inc.php ``` 请检查以下行是否正确: ``` $config['db_dsnw'] = 'mysql://username:password@localhost/database_name'; ``` 请将 "username"、"password" 和 "database_name" 替换为您的数据库用户名、密码和数据库名称。 2. MySQL 服务未运行 如果 MySQL 服务未运行,那么 Roundcube Webmail 将无法连接到数据库。您可以使用以下命令检查 MySQL 服务的状态: ``` sudo systemctl status mysql ``` 如果 MySQL 服务未运行,那么您可以使用以下命令启动它: ``` sudo systemctl start mysql ``` 3. 防火墙阻止连接 如果您的服务器上启用了防火墙,那么它可能阻止了 Roundcube Webmail 连接到 MySQL 数据库。请确保您已经允许 MySQL 数据库的入站连接。您可以使用以下命令检查防火墙规则: ``` sudo ufw status ``` 如果防火墙规则不允许 MySQL 数据库的入站连接,那么您可以使用以下命令添加规则: ``` sudo ufw allow mysql ``` 完成后,再次尝试连接数据库。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值