支持' XYZ'自创建数据库以来,上下文已更改

时间:2017-11-23 15:06:10

标签: entity-framework ef-code-first

我收到以下错误

支持' XYZ'自创建数据库以来,上下文已发生变化。

如何了解为记录目的而出现问题的实体/实体?

1 个答案:

答案 0 :(得分:0)

您遇到问题的实体名称当然是'XYZ',因为它在您发布的错误中指定了。

虽然我不确定你必须抓到哪个例外,你可能不应该这样做,但很明显你需要做什么。

以下是一些有用的信息:

The model backing the <Database> context has changed since the database was created

此处也有人讨论过:

Entity Framework 4.1 The model backing the context has changed since the database was created, immediately after creating DB

告知catch (PlatformNotSupportedException)可能是相关的。但我说过,这可能不是解决方案。

最后,问题可能更深入,如果是这样的话,请看看:

The model backing the '--Context' context has changed since the database was created - but db is new production database