问题描述
在我的应用程序中,我通过一些迁移启用了 Code First 迁移,我还使用 SQL Server Compact 进行集成测试.
当我运行测试时,Entity Framework 创建一个空数据库并尝试在该空数据库上运行迁移并抛出指定的表不存在.
根据 this 报告,我认为 Entity Framework 6 中迁移的使用发生了变化.p>
我使用 Context.Database.Create();
测试所有数据库初始化程序,但在所有情况下都没有创建 tabale.
我不知道这是否是EntityFramework的错误,但是当我将迁移配置类的命名空间从默认(Projectname/Migrations)重命名为任何没有默认名称,迁移效果很好.
In my application I enable Code First Migrations with some migrations, Also I use SQL Server Compact for integration test.
When I run my tests, Entity Framework create an empty database and tries to run migration on that empty database and thrown The specified table does not exist.
Based on this report I think usage of Migration in Entity Framework 6 has changed.
I test all Database Initializer with Context.Database.Create();
but in all case tabale's never created.
I don't know that this is EntityFramework's bug or not, but when I made rename the namespace of Migration Configuration class from default (Projectname/Migrations) to any none default name, migration works well.
这篇关于Entity Framework 6 - 启用迁移时不创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!