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:
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With