Data Sources Overview
Data sources represent the data available to your application. More specifically, data sources represent the data that you want to work with in your application. Data sources can be obtained from databases (including local database files), services, and objects.
The data sources that you add to your project are displayed in the Data Sources window. In many cases, you can drag data sources to the Windows Forms, WPF, and Silverlight designers to create controls that are bound to the underlying data. For more information, see Binding Controls to Data in Visual Studio.
Visual Studio provides tools for creating and editing data sources in your application. Data sources in Visual Studio projects are represented as Entity Data Models, datasets, proxy objects returned by a service, or other object types, depending on the objects that are returned by the underlying data store.
You create and edit data sources by using the Data Source Configuration Wizard.
Data Sources Created from Databases
You can create a data source from a database by running the Data Source Configuration Wizard and selecting the Database data source type. For more information, see How to: Connect to Data in a Database.
When you create a data source from a database, Visual Studio generates a data model and adds it to your project. A data model is a strongly typed, programmable view of the underlying data in the database. You can use Visual Studio to create the following types of data models:
A conceptual model based on the Entity Data Model. This type of model can be used by the Entity Framework or WCF Data Services. For more information, see Entity Framework Overview and WCF Data Services.
Typed dataset. For more information, see Working with Datasets in Visual Studio.
LINQ to SQL classes. For more information, see LINQ to SQL.
Note
Unlike Entity Data Model-based conceptual models and datasets, LINQ to SQL classes cannot be created by using the Data Source Configuration Wizard. They also do not appear in the Data Sources window, and therefore cannot be dragged to a designer to create data-bound controls. However, you can create an object data source that is based on LINQ to SQL classes, and drag those objects to the designer. For more information, see How to: Create LINQ to SQL Classes Mapped to Tables and Views (O/R Designer).
Data Sources Created from Local Database Files
You can also create data sources from the following types of database files: SQL Server Compact databases (.sdf files), Access databases (.mdb files), SQL Server Express LocalDB databases (.mdf files), and SQL Server Express databases (.mdf files). When you create data sources from these database files, you can add the database files directly to your project. For more information, see the following topics:
Data Sources Created from Services
You can create a data source from a service by running the Data Source Configuration Wizard and selecting the Service data source type. For more information, see How to: Connect to Data in a Service.
When you create a data source from a service, Visual Studio adds a service reference to your project. Visual Studio also creates proxy objects that correspond to the objects that are returned by the service. For example, a service that returns a dataset is represented in your project as a dataset; a service that returns a specific type is represented in your project as the type returned.
You can create a data source from the following types of services:
WCF Data Services. For more information, see ADO.NET Data Services Framework Overview.
Windows Communication Foundation (WCF) services. For more information, see Windows Communication Foundation Services and WCF Data Services in Visual Studio.
Web services. For more information, see Introduction to Programming Web Services in Managed Code.
Note
The items that appear in the Data Sources window are dependent on the data that is returned by the service. Some services might not provide enough information for the Data Source Configuration Wizard to create bindable objects. For example, if the service returns an untyped dataset, no items will appear in the Data Sources window upon completing the wizard. This is because untyped datasets do not provide a schema, and therefore the wizard does not have enough information to create the data source.
Data Sources Created from Objects
You can create a data source from any object that exposes one or more public properties by running the Data Source Configuration Wizard and then selecting the Object data source type. All public properties of an object are displayed in the Data Sources window. For more information, see How to: Connect to Data in Objects.
For more information about binding to objects, see Object Binding in Visual Studio.
Data Sources Created from SharePoint Lists
You can create a data source from a SharePoint list by running the Data Source Configuration Wizard and selecting the SharePoint data source type. SharePoint exposes data through WCF Data Services so creating a SharePoint data source is the same as creating a data source from a service. Selecting the SharePoint item in the Data Source Configuration Wizard opens the Add Service Reference dialog box where you connect to the SharePoint data service by pointing to the SharePoint server. For more information, see How to: Connect to Data in a Service.
See Also
Reference
Concepts
What's New for Data Application Development in Visual Studio 2012
Binding Windows Forms Controls to Data in Visual Studio
Preparing Your Application to Receive Data
Fetching Data into Your Application
Binding Controls to Data in Visual Studio
Editing Data in Your Application