1

I have a database and I want to make a model from it then later controllers and views. I went to "Models" folder then clicked on "Add New Item" but unable to find Entity Data Model. However Entity Framework 5 is already installed and reference is also present and I am using visual studio 2013 ultimate. I also tried nuget package manager but it is also confirming that Entity Framework is already installed. I think I am missing some thing or doing somthing wrong. Please help me how to generate a model from a database.

2 Answers 2

1

I uninstalled the visual studio and then installed it again. It solved my problem. Some components like visual studio database tools were not installed correctly. And it would also work if I would choose the repair option.

Sign up to request clarification or add additional context in comments.

1 Comment

What an unfortunate reality; repairing an 11G install isn't time consuming at all! BTW, pretty sure mine broke between Git commits and thus lost considerable changes; couldn't find any other viable reason.
-1

You'll need to creat an edmx file which captures your model from the database. the steps to do this are as follows:

To create an .edmx file from an existing database

  • Open or create the project for which you want to create an .edmx file.
  • Right-click the project name in Solution Explorer, point to Add, and then click New Item.
  • Select ADO.NET Entity Data Model in the Templates pane.
  • Enter the name for the file (.edmx), and then click Add.
  • The first page of the Entity Data Model Wizard appears.
  • Select Generate from database in the Choose Model Contents dialog box, and then click Next.
  • Click the New Connection button.
  • The Connection Properties dialog box appears.
  • Enter the server name, select the authentication method, and enter the name of the database for which the model is being created. Click OK.
  • The Choose Your Data Connections dialog box is updated with the database connection settings.
  • Click Next to continue.
  • The Choose Your Database Objects dialog box appears. By default, no objects in the database are selected for inclusion in the .edmx file.
  • Expand the nodes for Tables, Views, and Stored Procedures. Cancel the selection of any tables, views, and stored procedures that you do not want included in the .edmx file.
  • Click Finish to create the .edmx file.

this can be referenced more fully at: http://msdn.microsoft.com/en-us/library/vstudio/cc716703%28v=vs.100%29.aspx

[edit] - this is how the new item dialog should look:

enter image description here

Then when creating controllers/views, you just point to the required model in the select list, i.e:

enter image description here

6 Comments

But I got stuck at step 3, ADO.NET Entity Data Model is not showing in Templates, this was my real question.
remember, it's add new item, not template. look for the item type under visual c#->data. it's def there if using vs2012/13
Yes I am clicking "add new item" but ADO.NET Entity Data Model is not there. I am using visual studio 2013 ultimate with sql server 2012 enterprise.
i've added some screen shots to further illustrate what you should be seeing. if those items are missing, then you have something wrong with your installation and may need to go back and redo that. hope this helps
The problem with your answer is it gives a general way to do this in an environment that will allow it. The whole point is, once you do all the steps you've laid out, it doesn't work; there is no model created. My install was working correctly for a long time and out of nowhere it breaks. The only way, that I could find, to fix it is reinstall.
|

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.