Make Model from Database using ADO.NET Entity Framework - entity-framework

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.

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.

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:
Then when creating controllers/views, you just point to the required model in the select list, i.e:

Related

How can you update an Analysis Services tabular model with the changes in the data source?

After defining a model in a SQL Server Analysis Services Tabular project, the schema in an underlying data source may change. These changes are not automatically detected or updated in a project.
With multidimensional projects you can open the DataSource View right click on "refresh" to get the updates. However, I don't see similar functionality in tabular projects.
How can you update an Analysis Services tabular model with the changes in the data source?
For SSAS Tabular and Azure Analysis Services, for updates to the underlying schema, you have to go to the 'Table Menu' & Table Properties and edit the table properties. If you then click the refresh preview it will detect the changes and show the new columns. You have to select the tick boxes, to bring newly added columns to the main Tabular Model. You have to do this for all table, there isn't a full detect all changes option.
Question on msdn for reference More info here
Follow these steps to update the model after the underlying database changes:
Right click on a table and select Table 'Properties...'
Click the 'Design...' button
Click on the 'Query' menu
Click 'Refresh Current'

Add SQL command to report

I want to make a Crystal Report based on a SQL statement. I've read to do that, you add a command to the report, and to do that you have to connect to a database.
When I click the browse button I get the following screen:
Based on my research, it seems you connect to a database. As seen above, all of the file types are .xml files and all that shows up is Dataset. After I click on that, and right click on the dataset name node, the Add Command to Report is greyed out:
Normally you'd be able to add a custom SQL command by right clicking Add Command and selecting Add Command to Report However ADO.NET requires some unique steps in order to add the custom SQL. Instead you'll want to navigate here:
Create New Connection → OLE DB (ADO) → Microsoft OLE DB Provider for SQL Server
You'll of course supply the server information and pick the database.
After adding the connection:
1) Click the plus sign next to your connection.
2) Double-click the "Add Command" node.
3) Type in your SQL query, click ok.
Source: Crystal Reports 2016 Online Help chm file.
HTH,
aEon'

How to add new tables in to an exisitng Entity framework

I have EF where I added new tables like "Update Model from database" and saved ,but the tables are not created in either Context.cs file or into models. I closed Visual studio and restarted again, but still , I get the same problem. Is this a known and existing bug?
If you click Update model from database you get a window with a TabControl in it. The tab items are Add, Refresh and Delete. From the Add tab check from the treeview the tables that you want to add. Then those selected tables are inserted into the edmx file
To update the .edmx file when the database changes
In the Model Browser, right-click the .edmx file and select Update Model from Database.
The Update Model Wizard starts. If there is no database connection specified, the Choose Your Database Connection dialog box appears. Otherwise, the Choose Your Database Objects dialog box appears.
If the Choose Your Database Connection dialog box appears, specify a database connection. Otherwise, go to the next step.
For details about specifying a connection, see Choose Your Data Connection Dialog Box (Entity Data Model Wizard). When you have specified the connection, click Next to display the Choose Your Database Objects dialog box.
Click the Add tab.
Nodes for tables, views, and stored procedures are displayed. If any objects have been added to the database (or were not included in the previous storage model), you can expand the corresponding node to view the objects that are available to add to the conceptual model.
Note
If an object has been deleted from the conceptual model but has not also been deleted from the storage model, the object will not be available to add to the conceptual model. For more information, see How to: Delete Objects from the Storage Model (Entity Data Model Tools).
Expand the Tables, Views, and Stored Procedures nodes, and check the objects you want to add to the .edmx file.
Click the Refresh tab.
Nodes for tables, views, and stored procedures that are included in the existing storage model are displayed. Any changes that have been made to these database objects will be reflected in the updated storage model. Changes to the conceptual model are made when columns are added to a table or view.
Click the Delete tab.
Nodes for tables, views, and stored procedures are displayed. If an object has been deleted from the database and was included in the previous storage model, you can expand the corresponding node. The objects in these nodes will be deleted from the updated model.
Click Finish to update the .edmx file with the database changes.
Find the complete reference here:
Update Entity Data Model

Generate Database menu item in Entity Modeler only brings up Save to DDL Wizard

I'm using VS2K13.3, and have a connection setup in my Entity Data Model (model first) to an Azure database.
When I right click on the surface of the modeler and select Generate Database, all I get is a dialog to save the model to a DDL script in my project. I don't get a wizard to publish the model and generate a database on an external database (for instance Azure).
Online tutorials show a different result. Any idea why this might be happening?
For example when reading these instructions, the dialog that I get is not what's described within this linke: http://msdn.microsoft.com/en-us/library/vstudio/dd456815(v=vs.100).aspx
I reread this and apparently it's working as described. How then do you get the DDL executed in Azure SQL?

Reporting Services Deployment Problem Deploying from VS 2005 to RS 2008

I've got a report that works perfectly in development previews. But when I deploy I get the following error:
In the Dev Environment the Error displayed is:
Error 4 The data source 'myDataSource'
cannot be found. c:\reporting services
projects\reports\rest_of_path\my_report.rdl
0 0
On the reporting services side the error it shows is:
The data source connection information
has been deleted.
(rsInvalidDataSourceReference)
By itself the datasource deploys just fine and it's present on the server so it doesn't make sense that it "can't find" it. What is going on?
P.s. I found a way to make it work on the server by manually assigning the datasource link that's lost in deployment. But I'd rather not have to do this every time I deploy a new report.
go to Report Manager(http:///reports/pages/Folder.aspx)
Click on the Folder in which u have reports
U will be directed into contents tab where u will find Show Details at the right top corner
Click on Show Details
Check in the particular report and click the edit button corresponding to it
Go to the properties tab and click on it
U will find a menu on left hand side, click on Data Sources link
There u will find radio button selected for A share data source(by default) and a browse button.
Click on the browse button u will find the tree structure of the datasource and the reports folder.
select the datasource in the datasource folder and select OK.
(From a post on http://social.msdn.microsoft.com/forums/en-US/sqlreportingservices/thread/622dc981-4378-4331-b2fc-e377660464df/)
Did you upgrade the report files? the RDL spec changed between 2005 and 2008, you need to ensure that you are working with 2008 compatible tools if you are targeting 2008.
I got this to work with 2005, and to make it work I had to change the data source to use OLE DB and Sql Server Native Client 10.0. Another strange quirk was that the data source had to not have spaces in the name. I then had to reassign the report to use the new data source without spaces and then the 2005 rdl worked on the 2008 server.