如何正确删除和重新添加实体数据模型 [英] How to properly delete and re-add Entity Data Model

查看:297
本文介绍了如何正确删除和重新添加实体数据模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此处是Entity Framework的新手。使用VS 2010和SQL Server 2008 Express数据库。

newbie to Entity Framework here. Using VS 2010 and SQL Server 2008 express DB.

我在添加新表后无法刷新实体数据模型。因此,我遵循了在这里找到的建议,即删除并重新生成模型。

I was having trouble refreshing an Entity Data Model after adding new tables. So, I followed a suggestion I found here to just delete and regenerate the model.

我进入实体数据模型向导的选择数据连接部分,然后选中将Web.config中的实体连接设置另存为:。但是,我现有的名称后面附加了1。例如,MyDatabaseEntities现在是MyDatabaseEntities1。当然,我不希望附加 1。我杀死了Web.config中现有的连接字符串,并在解决方案中删除了对该名称的所有引用。但是,当我尝试继续时,出现以下错误:

I get to the "Choose Your Data Connection" section of the Entity Data Model Wizard and "Save entity connection settings in Web.config as:" is checked. However, my existing name has a 1 appended to it. For example MyDatabaseEntities is now MyDatabaseEntities1. Of course, I don't want the "1" appended. I killed the existing connection string in Web.config and removed all references to that name in my solution. Yet when I try to continue I'm presented with the following error:

'MyDatabaseEntites'与应用程序设置中的现有属性名称冲突。请选择其他名称

"'MyDatabaseEntites' conflicts with an existing property name in the Application Settings. Please choose a different name"

我在解决方案中的任何地方都找不到对该名称的引用。我可以取消选中该选项,该选项将继续,但仍不会在数据库中添加两个表。接下来,我完全关闭了所有设备,重新启动,然后重试。这次我没有得到上面的错误,但是我的三个新表中的两个仍然没有添加到edmx模型中。

I can't find a reference to that name anywhere in the solution. I can uncheck that option and it will continue, but it STILL won't add two of the tables in the database. Next, I completely shut everything down, rebooted, and tried again. This time I didn't get the error above, but two of my three new tables still do not get added to the edmx model.

任何想法都值得赞赏。同样,即使在VS2010 / .NET 4中,这似乎仍然是个错误。帮助恢复我的信念……我现在很想放弃Entity Framework。根据我到目前为止的经验以及此处发布的一些其他问题,我觉得比起编写有用的代码,我将花费更多的时间来追求Entity Framework的陌生性。

Any ideas are appreciated. Also this seems like it's still pretty buggy even in VS2010/.NET 4. Help restore my faith...I feel like abandoning Entity Framework at this point. Based on my experience so far and some of the other issues posted here, I feel like I'm going to spend more time chasing Entity Framework strangeness than writing useful code.

更新:我找到了解决方法。设计器不会显示错误。您必须查看本机XML(edmx文件)以查看错误。参见此处: ADO.NET实体框架:更新向导将不添加表

UPDATE: I found a resolution. The designer doesn't display errors. You have have to look in the native XML (edmx file) to see the errors. See here: ADO.NET Entity Framework: Update Wizard will not add tables

推荐答案

该错误是由 App.Config文件中设置中的剩余连接字符串引起的(请参阅解决方案资源管理器),它在本节中:
connectionStrings(由尖括号包围)

The error is caused by leftover connection strings in settings in "App.Config" file (see solution explorer) and it's in this section: "connectionStrings" (surrounded by angle brackets)

只需从此处删除它即可。

Just delete it from there.

这篇关于如何正确删除和重新添加实体数据模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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