VKinfotek Inc.
  • Us
    About Us
    Contact Us
  • FAQs
  • Ready Software
    Ready ERP ASP Core Software for Azure Cloud
    Ready Web ERP Software
    Ready ASP.Net Azure Software
    Ready C# SQL Server Accounting Software
    Ready ASP.Net MVC and EF Software
Earn $100/hour in USA! Click Here

Q101. Connect to Windows Azure SQL Database Using the ADO.NET Entity Framework?

The ADO.NET Entity Framework enables developers to create data access applications by programming against a conceptual application model instead of programming directly against a relational storage schema. This topic shows how to create a simple conceptual model that is mapped to a Windows Azure SQL Database and query over the conceptual model.

Let us consider a school administration code example. In this example, we create strongly-typed query against the CLR objects that represents entities and associations. This query returns the department names in the school. To follow this example, you must install the Entity Framework from the .NET Framework 3.5 Service Pack 1 or later versions.

Create the data model


In Visual Studio, on the File menu, point to New, and then click Project.

In the Project types pane, select Windows. In the Templates pane, select Console Application. Enter SchoolApplicationEF as the Name, and then click OK.

In Solution Explorer, right-click SchoolApplicationEF, point to Add, and select New Item.

Select ADO.NET Entity Data Model, enter SchoolDataModel.edmx as the Name, and then click Add.

In the Entity Data Model Wizard, select Generate from database and then click Next.

Click New Connection, and enter the information for the School database on your SQL Database server, click OK. Then, click Next. Select Tables and then click Finish. This creates an .edmx file that defines an entity type for each table in the database. Save the SchoolDataModel.edmx file.

When running this code, the Entity Framework cannot create the .edmx file and related client classes from a SQL Database. It must connect to a local instance of SQL Server to generate the model and mapping files. However, the Entity Framework will connect to Windows Azure SQL Database when the model and mapping files have been created.

Create the Console Application


Replace the code in your program file with the following code, and then press F5 to run the application against your SQL Database.

connecting to azure sql database using ado.net entity framework
  • Prev Question
  • Next Question

See More Questions and Answers on - Azure SQL Server

  • Two models of using SQL Server in the cloud
  • Choose between SQL Server in vm and sql database
  • How to access data in Azure sql databas
  • Create and configure SQL database server in the cloud
  • How to configure the SQL database firewall
  • How to connect SQL database instance with SQL Server management studio
  • How to connect to a SQL database with ado.net
  • Build a Azure application that works with SQL database

Back to Master List of 100+ Questions and Answers

People also viewed: cover image of book develop erp software using asp core and deploy to Azure Create your own ERP Software using ASP Core>>
cover image of azure cloud book Create your own Azure SOM Software>>
cover image of asp.net book Create your own ERP Software using ASP .Net and SQL>>
cover image of foundation database programming book Create your own Accounting Software using C# >>
cover image of entity framework book Create your own SOM using Entity Framework MVC >>

  • SITEMAP
  • Terms of use
  • Testimonials

Back to top

Copyright © 2018 - All Rights Reserved - VKInfotek.com