.net 实体数据模型设计器不会打开 edmx 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14883861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-03 16:52:59  来源:igfitidea点击:

Entity data model designer won't open the edmx file

.netado.netmappingentity-framework-5edmx

提问by Legion

The strange thing is, it was working fine a few days ago. I added a new column to a table and was going to update the model through the designer and now it says "The Entity Data Model Designer is unable to display the file you requested. You can edit the model using the XML Editor."

奇怪的是,几天前它运行良好。我向表中添加了一个新列,并打算通过设计器更新模型,现在它显示“实体数据模型设计器无法显示您请求的文件。您可以使用 XML 编辑器编辑模型。”

There's nothing particularly noteworthy about the new field, it's just a non nullable bit field in SQL Server 2008.

新字段没有什么特别值得注意的,它只是 SQL Server 2008 中的一个不可为空的位字段。

采纳答案by Legion

Fixed by deleting the file and regenerating it.

通过删除文件并重新生成来修复。

回答by Charlie

FOR Visual Studio 2017

适用于 Visual Studio 2017

I searched for the solution but come up with the installation of some NUGET packages and Extensions, nothing worked out.

我搜索了解决方案,但想出了一些 NUGET 包和扩展的安装,但没有成功。

Solution(Missing Entity Framework on Visual Studio)

解决方案(Visual Studio 上缺少实体框架)

  1. I searched for Visual Studio Installeron my machine and opened it.
  2. Under Visual Studio Professional 2017.
  3. I clicked on Moreto see more options. I selected Modify
  4. Select Individual Components(Second Tab)
  5. Check Entity Framework Under SDKs, libraries, and framework
  6. and then click Modify EDMX file will opens after the process gets completed.
  1. 我在我的机器上搜索了Visual Studio Installer并打开了它。
  2. Visual Studio Professional 2017 下
  3. 我单击“更多”以查看更多选项。我选择了修改
  4. 选择单个组件(第二个选项卡)
  5. 检查SDK、库和框架下的实体框架
  6. 然后单击修改 EDMX 文件将在该过程完成后打开。

回答by Ashley

I also encounter that annoying screen. No, I do NOT want to edit my model in XML... I want the pretty designer! In my case I added a table which did not have a primary key. To fix...

我也遇到那个烦人的屏幕。不,我不想在 XML 中编辑我的模型......我想要漂亮的设计师!就我而言,我添加了一个没有主键的表。修理...

1) Open the edmx in XML

1) 用 XML 打开 edmx

2) Delete the erroneous table. It should be well defined with an "<-- ERROR" comment.

2) 删除错误表。它应该用“<-- ERROR”注释很好地定义。

3) Clean and Rebuild.

3) 清理和重建。

4) Close and re-open Visual Studio (yes, it's annoying but necessary)

4)关闭并重新打开Visual Studio(是的,这很烦人但很有必要)

5) Rebuild one more time, then open your edmx file. Should open the designer fine.

5) 再重建一次,然后打开您的 edmx 文件。应该打开设计器就好了。

Hope this helps.

希望这可以帮助。

回答by Dmass

This has happened to me a few times, usually when pulling a solution out of subversion. Rebuilding the project has always fixed the issue for me.

这在我身上发生过几次,通常是在从颠覆中提取解决方案时。重建项目总是为我解决这个问题。

回答by Edgar

This happened to me when I added a field to an table that was used in a function as RETURN (SELECT TableName.* .... )

当我将一个字段添加到在函数中用作 RETURN (SELECT TableName.* .... ) 的表中时,发生了这种情况

The CollectionSet subnode of the ReturnType node for that function in the EDMX wasn't refreshed.

EDMX 中该函数的 ReturnType 节点的 CollectionSet 子节点未刷新。

To fix it, you need to simply run ALTER FUNCTION (without actually changing it), then update the model from database within Visual Studio.

要修复它,您只需运行 ALTER FUNCTION(而不实际更改它),然后从 Visual Studio 中的数据库更新模型。

回答by Fireman Sam

This happens to us quite a bit (usually from a bad merge) and our EDMX file is over 50k lines, which makes eyeballing the problem impossible. However, firstly, you can use one of the online XML parsers (eg. https://onlinexmltools.com/validate-xml) to determine if the XML is correct. Once the XML is valid, the file should at least open in the XML editor (I assume you are using Visual Studio): you can then use Alt+PageDn (Edit > Goto > Next Issue) - the wiggly underscore and associated tip are often of genuine help. I have managed to resurrect our EDMX several times this way.

这在我们身上发生了很多(通常来自错误的合并)并且我们的 EDMX 文件超过 50k 行,这使得不可能通过眼球来解决问题。但是,首先,您可以使用在线 XML 解析器之一(例如https://onlinexmltools.com/validate-xml)来确定 XML 是否正确。一旦 XML 有效,该文件至少应该在 XML 编辑器中打开(我假设您使用的是 Visual Studio):然后您可以使用 Alt+PageDn(编辑 > 转到 > 下一期)——摆动的下划线和相关提示通常是真正的帮助。我已经设法以这种方式多次复活我们的 EDMX。

回答by Alejandro Tobón

Some times this issue happens because the XML representation of the model has some conflicts. In my case, the error was caused because the model had a conflicted reference, in other words, there was a reference to a table that was manually removed in the XML and the removal wasn't done properly (they leaved the EntityType reference but removed all the rest).

有时会出现此问题,因为模型的 XML 表示存在一些冲突。在我的例子中,错误是因为模型有一个冲突的引用,换句话说,有一个对在 XML 中手动删除的表的引用,并且删除没有正确完成(他们留下了 EntityType 引用但删除了其他的)。

I just opened the XML file and the issue was underlined, I just removed it, and it fixed the issue, the model was shown without any problems.

我刚刚打开 XML 文件,问题被加下划线,我刚刚删除它,它解决了问题,模型显示没有任何问题。

回答by Leniel Maccaferri

In Visual Studio 2019 I could solve the problem by opening the .edmx file using the built-in XML editor.

在 Visual Studio 2019 中,我可以通过使用内置 XML 编辑器打开 .edmx 文件来解决问题。

Visual Studio shows the error(s) underlined like this:

Visual Studio 显示如下带下划线的错误:

enter image description here

在此处输入图片说明

Check the Error List window (red X icon)...

检查错误列表窗口(红色 X 图标)...

Once you get rid of all errors, then the designer will show as expected.

一旦你摆脱了所有的错误,那么设计器就会按预期显示。

回答by JM Kumawat

This can be the case when we migrate visual studio solution from an older version to VS 2017/2019. So, I solved it by performing the following steps (changes are highlighted in bold): 1. Change:

当我们将 Visual Studio 解决方案从旧版本迁移到 VS 2017/2019 时,可能就是这种情况。因此,我通过执行以下步骤解决了它(更改以粗体突出显示): 1. 更改:

<edmx:Edmx Version="2.0" xmlns:edmx="http://schemas.microsoft.com/ado/2008/10/edmx">

To

<edmx:Edmx Version="3.0" xmlns:edmx="http://schemas.microsoft.com/ado/2009/11/edmx">
  1. Change (all occurrence):
  1. 更改(所有发生):
<Schema Namespace="SilverAndgemModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2008/09/edm">

To

<Schema Namespace="SilverAndgemModel" Alias="Self" xmlns="http://schemas.microsoft.com/ado/2009/11/edm">

Once complete, close and open the edmx again.

完成后,关闭并再次打开 edmx。

This should solve the problem.

这应该可以解决问题。

回答by Ege Bayrak

I just had the same problem after a merge. Luckily, undoing the changes to the edmx and related files in checkin window and re-adding the new files solved it for me.

合并后我遇到了同样的问题。幸运的是,在签入窗口中撤消对 edmx 和相关文件的更改并重新添加新文件为我解决了这个问题。