Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly delete and re-add Entity Data Model

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.

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' conflicts with an existing property name in the Application Settings. Please choose a different name"

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.

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.

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

like image 616
David Avatar asked Jan 06 '11 17:01

David


People also ask

How do I remove EDMX and regenerate?

There is no automatically refresh the EDMX (it will be nice from MS if they implement that at some point) and the best and most accurate way to refresh the EDMX is by deleting all tables in the Diagram and then deleting all complex types etc. in the Model Browser.

How do I delete data in entity Framework?

Delete a Record In Connected Scenario, you can use the Remove or RemoveRange method to mark the record as Deleted . In Disconnected Scenario, you can attach it to the context and set its state as Deleted . Calling SaveChanges will send the delete query to the database.


1 Answers

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.

like image 54
techvslife Avatar answered Sep 21 '22 18:09

techvslife