Entity Data Model Wizard does not show new tables

I have created sql database from scripts using Microsoft SQL Server 2012 and generated some classes in C # using entity framework. Now I had to change and add several new items to this base, including stored procedures and new tables.

However, when I try to regenerate classes in Visual Studio Ultimate 2012, the Entity Data Model Wizard still shows the old database (as it looked a week ago), including some tables I deleted. None of the new materials listed. I tried deleting and re-creating the database, restarting both programs, and restarting my computer without any consequences.

The steps I take to create a framework in Visual Studio are as follows:

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

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

UPDATE:

I have the advantage of the "Update Model from Database" option, but my Visual Studio doesn't have that option. A web search shows that it was found in a "model browser window" which I also did not find in VS. Further searches show that this window becomes available after opening the "edmx" file. I searched all over pc for this file extension and found some results, but they are all from other peoples projects. I cannot find the .edmx related to either the C # solution or the sql database for this project.

+3


source to share


3 answers


In the Entity Data Model Wizard, on the Select Data Connection screen, I selected New Connection instead of clicking Next on the existing connection. Selecting the server name and database name and reconnecting to the connection seems to update the view and there are now new tables.

I had a feeling that this would be the small tenth thing I was missing.

UPDATE:



On reconnection, the new tables are available, but not the stored procedures. This is how I fixed it.

In the Model Wizard, choosing "Code First From Database", for some reason, stored procedures will not be stored. For me, the correct option was "EF Designer from Database". Not only did I get new tables AND stored procedures, but I also created an edmx file that the first option didn't create.

+2


source


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

  • Build, Clean Solution
  • Remove connected lines from web.config
  • Delete all files in the "Models" folder
  • Right click the Models folder, Add, New Item
  • Select ADO.NET Entity Data Model
  • Add name to model
  • Select Code First From Database
  • Select a new connection
  • Save connection settings to web.config - checked

I found out that this is because there is no primary key in the table. So I changed the table



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

      

and it worked.

In case anyone comes across this, I hope this helps.

+1


source


I had this problem and it turned out that the SQL user that is being used does not have the choice of accessing the newly created tables.

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

Running the update model from the database then showed the new tables.

+1


source







All Articles