Entity Data Model Wizard Not Showing New Tables

29,574

Solution 1

In the Entity Data Model Wizard, on the "Choose Your Data Connection" screen, I chose "New Connection" rather than hitting "Next" with the existing connection. Choosing the server name and database name and redoing the connection seems to refresh the view, and now the new tables have shown up.

I had a feeling it was going to be some small, ten-second thing I was missing.

UPDATE:

Redoing the connection made the new tables available, but not the stored procedures. Here's how I fixed it.

In the Model Wizard, choosing "Code First From Database" won't include stored procedures, for whatever reason. For me, the correct option was "EF Designer from Database". Not only did I get the new tables AND stored procedures, but it also generated the edmx file that the first option wouldn't create.

Solution 2

I had a similar problem with Code First. I followed all the steps mentioned on the question, but the model for the table was not being generated.

  • Build, Clean Solution
  • Delete conn strings from in web.config
  • Delete all files in Models folder
  • Right click on Models folder, Add, New Item
  • Select ADO.NET Entity Data Model
  • Add name to Model
  • Select Code First from database
  • Select New Connection
  • Save Connection Settings in web.config - Checked

I found out it was because the table did not have a primary key. So I altered the table

[OrderId] [int] not null identity(1,1) primary key,

and it worked.

In case anyone runs into this, I hope it helps.

Solution 3

I had this problem and it turned out to be the SQL user being used did not have select access to the newly created tables.

I ran GRANT SELECT ON [tablename] to [sqluser] on the database for all the new tables. You could also just add the sql user to a server role like sysadmin.

Running Update Model from Database then showed the new tables.

Solution 4

I removed a table and did not see it to re-add it. I had incosistent EDMX file. I had to remove all references to that table from Model Browser window when editting EDMX file, than the table reappeared in EDMX editor and I was able to re-add it.

As proposed bellow by Mukesh Kumar (thanks), you can do it in text editor (but you have to know what you are doing), but I would go for this solution as the last possibility not to create some more inconsistencies in EDMX file.

Share:
29,574
Nightmare Games
Author by

Nightmare Games

Developer of strange video games and other tech, Nightmare Games lives at BurningFreak.com and is always hard at work on its next interactive audio-visual sensory onslaught. We currently operate out of the greater Seattle area with part-time help from our partners in Pennsylvania and Iowa. Completed Projects: Photon (C++ 2D Graphics Engine) Outlaw JS (Javascript 2D Game Engine) Ultraguy (Browser Game) Wobbly Piss (Browser Game) Blockhead (Xbox 360 / Windows / WP7 Game) Current Projects: H0V3R (C# Unity Game) Super Krampus (C++ Windows Game) Blockhead (Javascript Browser Game) Engineer (MVC Browser Game) Boxland Incorporated (C# Windows Game)

Updated on February 09, 2021

Comments

  • Nightmare Games
    Nightmare Games over 3 years

    I've created a sql database from scripts using Microsoft SQL Server 2012 and generated some classes in C# using the entity framework. Now I've had to modify and add a number of new items to that database, including stored procedures and new tables.

    However, on trying to regenerate the classes in Visual Studio Ultimate 2012, the Entity Data Model Wizard is still showing the old database (the way it looked a week ago), including some tables I deleted. None of the new stuff is listed. I've tried deleting and recreating the database, restarting both programs, and restarting the pc to no effect.

    The steps I'm taking to generate the framework in Visual Studio are:

    • Add a new item to the project.
    • Select ADO.NET Entity Data Model.
    • Select Code First from database.
    • Select Next (the connection string is already filled in).
    • The next screen is the "Choose Objects and Settings" window, which is where I'm still seeing the old tables (and not the new ones).

    Is there some special step I need to take after changing a database to get those changes to show up in the entity framework?

    UPDATE:

    I've got a lead on an option to "Update Model from Database", but my Visual Studio has no option like this. Web searches indicate it's found in the "Model Browser Window", which I've also not found in VS. Further searches indicate this window becomes available after opening an "edmx" file. I've searched the entire pc for that file extension and found some results, but they are all from other peoples' projects. I can't locate a .edmx associated with either the c# solution or the sql database for this project.

  • Mukesh Kumar
    Mukesh Kumar over 4 years
    I opened the EDMX file in a text editor and looked for the object name's occurrence in it. Then, I found one occurrence and deleted that XML line from the file and saved it. After deleting it, the ADD wizard started showing the object. Thanks, Honza.
  • Gerry
    Gerry about 3 years
    Except Visual Studio won't let me change the data connection for some reason, it is skipping past Choose your data connection and disabling the Previous button. Argh!