How to cope with “No data stores are configured”?

半腔热情 提交于 2019-12-13 04:32:19

问题


I am currently playing with beta4 of EF7 using the blank ASP.NET web project template.

After having kicked off the existing migration, resulting in the tables being created in the localdb, the following occurs:

Strangely, when I clean up the migration-folder, including removing ApplicationDbContextModelSnapshot.cs and I run dnx . ef migration add twice, I get the following error:

dnx : System.InvalidOperationException: No data stores are configured. Configure a data store by overriding OnConfiguring in your DbContext class or in the AddDbContext method when setting up services.

The second migration is not created. When I review the created migration it contains all tables whereas the database is already provisioned, so you should expect the migration being empty.

Then, when I remove the first migration and run the add migration command again more than once, all the migrations are correctly created, i.e. as empty files.

Can someone explain this to me? Is this expected behavior or is this a bug in beta4?

Tip for people coming from former EF-versions: * Don't use the K command framework anymore. * Don't use the Add-Migration cmdlets anymore. Both have been replaced by dnx . (dot). (dnx = .NET execution environment)

Some references: https://github.com/aspnet/EntityFramework/wiki/Entity-Framework-Design-Meeting-Notes---September-11,-2014 http://jameschambers.com/2015/05/project-k-dnvm-dnx-dnu-and-entity-framework-7-for-bonus-points/


回答1:


Remove the constructor of ApplicationContext. It is a temporary workaround to enable deployment, but it interferes with the Migrations commands.



来源:https://stackoverflow.com/questions/30954372/how-to-cope-with-no-data-stores-are-configured

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!