5

In a class library Ado.net Entity Data Model is has generated POCO classes. These were generated fine for the first time. But database changes are not being reflected. In edmx diagram right clicking and choosing Update Model from Database show newly created table but it do not add table even after selecting it to add.

I tried running .tt (by right click and Run custom tool) but even it did not regenerated the Poco classes as per latest DB changes.

Help please

2
  • On the second tab, did you select the table you wanted to refresh ? Commented Sep 9, 2014 at 5:33
  • Make sure to save the edmx file after doing Update Model from Database Commented Jul 25, 2017 at 17:23

3 Answers 3

7

Not a fix but a workaround: Is it not an option to simply remove and regenerate the EDMX and the generated classes? That's what I do, it is much easier than working with the update feature, and the result seems to be the same. Your POCO extensions still remain the same and functional.

I use database first and I have my SQL upgrade scripts, the generated EDMX and my Generated models in source control and the changes there are very easy to manage. Here is a rough outline of my DB upgrade process for each version:

  1. Create .sql script for the upgrade, statements like CREATE TABLE etc.
  2. Delete generated files: Model.Context.tt, Model.tt, Model.edmx
  3. Remove Entities string from Web.config (if you use it)
  4. Create the EDMX and Context files the same way you did for the first time
  5. If you use source control (I hope you do!) check what has changed
  6. Test
  7. Commit!
Sign up to request clarification or add additional context in comments.

Comments

0

In my case i needed to save ModelName.edmx, then classes were generated.

Comments

0

Ensure that connections string in app.config is correct. I was using a DataDictionary and my connection string had the following path:

data source=|DataDirectory|*.sqlite

Thus, it wasn't updating. Because this DataDirectory variable was being resolved at runtime.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.