如何应对“未配置任何数据存储”? [英] How to cope with "No data stores are configured"?

查看:124
本文介绍了如何应对“未配置任何数据存储”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在使用空白的ASP.NET Web项目模板来玩EF7的beta4。

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

开始现有的迁移后,导致在localdb中创建表,发生以下情况:

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

奇怪的是,当我清理迁移文件夹,包括删除ApplicationDbContextModelSnapshot.cs并运行
dnx时。如果迁移两次,则出现以下错误:

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:未配置任何数据存储。设置服务时,通过在DbContext类或AddDbContext方法中重写OnConfiguring来配置数据存储。

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.

然后,当我删除第一个迁移时,多次运行add migration命令,所有迁移均已正确创建,即为空文件。

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.

有人可以向我解释吗?这是预期的行为还是beta4中的错误?

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

针对来自以前EF版本的用户的提示:
*不要使用K命令框架不再。
*不再使用Add-Migration cmdlet。
都已被dnx取代。 (点)。 (dnx = .NET执行环境)

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)

一些参考:
https://github.com/aspnet/EntityFramework/wiki/Entity-Framework-Design-Meeting-Notes--- 2014年9月11日
http://jameschambers.com/2015/05/project-k-dnvm-dnx-dnu-and-entity-framework-7-for-bonus-points/

推荐答案

删除 ApplicationContext 的构造函数。这是启用部署的临时解决方法,但会干扰迁移命令。

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

这篇关于如何应对“未配置任何数据存储”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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