Updating your edmx to reflect changes made to your db (.net linq-to-entity)

  • So I have my edmx.
  • Then I change my database a bit, changing the column to NOT NULL to allow NULL.
  • I go to my edmx, right click and select "Update Model From Database".

Now I go into my program, and it really does not update ... I cannot put zero in a column. What do I need to do to properly update edmx? Thank.

+41
linq linq-to-entities entity-framework
Mar 27 '09 at 15:34
source share
10 answers

Selecting an upgrade model from the database is the best way to upgrade your EDMX. There are certain properties that are not updated at the Conceptual level.

Make sure your Store level is updated by viewing it in the Model Viewer toolbar. If the store has been updated correctly, then everything is in order and your database is synchronized. If so, go to the visual designer, click on the field, go to properties and update the NotNull property on the Conceptual side.

+15
Mar 27 '09 at 15:52
source share

Updating / uninstalling from EDMX does not always work. If the model does not update when you click "Update model from the database," say, when you updated the view / table in the database, do the following:

1) Remove view / table from model diagram
2) Switch EDMX to xml view (right-click the edmx file and select "Open With")
3) Search and delete xml entity elements
4) Return to EDMX mode

5) Click "Update Model from Database"

This should reflect any changes you make to the database on your EDMX. It is bulky, but works flawlessly.

In an ideal world, I would expect the database update model to synchronize changes from DB to EDMX. But this does not work most of the time.

+79
Oct 08 '09 at 1:33
source share

I have successfully completed this (VB.Net).

  • Perform database updates as desired / required
  • Select "Update from database" in the EDMX model, the graphical model will correctly display the new structure / tables
  • Expand the project so that it shows all related files
  • Two files with the extension "tt" are those that matter: first take one of the WITHOUT. Context. before tt extension. right-click on it and select "Run Custom Tool":

run custom tool

  1. Do the same for the .tt file with .Context. on his behalf. All of your code and logical model classes will be updated.
+19
Oct 09
source share

Yes, it does not work most of the time: - /

The โ€œbest methodโ€ (because it works systematically) is to delete the EDMX file and generate it again. But do not forget to delete the connection string in App.config (otherwise VS2008 wizzard will add a suffix to the default name of the object) and clear the cache.

I hope these tools will work better in the next release because it drastically reduces performance ...

+6
Dec 15 '09 at 15:48
source share

THIS IS A QUICK EASY WAY:

  • Remove view / table from .edmx chart.
  • NOW use the update model from the database to add the table back.
+5
Jun 13 '14 at 21:39
source share

1.Build project after updating the EDMX file.

2. Right-click the .tt file in Solution Explorer.

3. Select "Run Custom Tool."

This will update the .tt file.

Source: here !

+5
Apr 24 '15 at 11:35
source share

Open the edmx file in the VS XML editor and check for errors that occurred while trying to upgrade.

<!--Errors Found During Generation: warning 6013: The table/view 'foo.dbo.snafu' does not have a primary key defined and no valid primary key could be inferred. This table/view has been excluded. To use the entity you will need to review your schema, add the correct keys and uncomment it. <EntityType Name="snafu"> <Property Name="snafu_column" Type="smallint" /> </EntityType>--> 

In the above case ... Adding a primary key to the table in question caused the "Update Model from Database" job.

+3
Jan 14 '10 at 19:01
source share

It does not update, for example, the maximum length for string attributes!

If you are working with TFS, it is not good to delete a file; you want to save the history and not affect others.

This works for me, having a separate project that I can use to completely recreate the edmx file, I open it in xml, copy it to the existing one and move one shape in the model so that VS will recreate the .cs file. Voila, now it is updated.

+2
Oct 27 '10 at 20:09
source share

This answer is better: stack overflow

Any manual editing is suitable for errors or will be lost if someone uses any tool, such as a wizard. Removing and updating using the wizard is much better.

+2
Oct 02 '14 at 16:46
source share

Removing all tables from the designer view and updating after that works for me

0
Sep 19 '17 at 8:38 on
source share



All Articles