How to cope with "No data stores are configured"?

entity-framework-core

Question

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/

Popular Answer

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



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why