实体框架6 - 启用迁移时不创建表 [英] Entity Framework 6 - Does not create tables when enabling Migrations

查看:262
本文介绍了实体框架6 - 启用迁移时不创建表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序中,我通过一些迁移启用了代码优先迁移,另外我使用SQL Server Compact进行集成测试。



当我运行测试时,Entity Framework创建一个空数据库,并尝试在该空数据库上运行迁移,并引发指定的表不存在。



基于这个报告我认为实体框架6中的迁移使用已经改变。



我使用 Context.Database.Create(); 测试所有的数据库初始化程序,但在所有情况下,tabale从未创建。

解决方案

我不知道这是EntityFramework的错误,但是当我将Migration Configuration类的命名空间从默认(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.

这篇关于实体框架6 - 启用迁移时不创建表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆