我在我的生产服务器上收到此错误,但该应用程序在本地运行正常

I get this error on my production server, but the application works locally just fine

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.

谁能解释为什么?

如果您的开发系统正常工作而生产系统不工作,您可以生成一个脚本使它们恢复同步:

update-database -Script –SourceMigration $InitialDatabase

这将创建一个幂等脚本,用于测试已应用和未应用的内容。现在使用 SQL Server Management Studio 应用该脚本。

https://msdn.microsoft.com/en-us/data/jj591621.aspx?f=255&MSPPError=-2147217396#idempotent