ASP.NET Data Access Content Map
This topic provides links to documentation resources about how to access data in ASP.NET web applications, primarily by using the Entity Framework and SQL Server.
If you know a great blog post, stackoverflow thread, or any other link that would be useful, send us an email with the link.
The topic contains the following sections:
- Getting Started with Data Access in ASP.NET
- Using the Entity Framework
- Using Entity Framework Code First
- Using Entity Framework Code First Migrations
- Using Entity Framework Database First or Model First (the EF Designer)
- Loading Related data in Entity Framework (Lazy Loading, Eager Loading, and Explicit Loading)
- Optimizing Entity Framework Performance
- Handling Concurrency in an Entity Framework Application
- Books about the Entity Framework
- Additional Entity Framework resources
- Data Binding in ASP.NET Web Forms Applications
- Working with SQL Server Databases
- Working with NoSQL Database Management Systems
- Using LINQ queries in ASP.NET Applications
- Using Dynamic Data scaffolding
- Securing Data Access
- Optimizing Data Access Performance
- Deploying a Database
- Accessing Data through a Web Service
- Additional Resources
Getting Started with Data Access in ASP.NET
- Get Started with ASP.NET & ASP.NET MVC (If you haven’t worked with ASP.NET, start here for a basic introduction.)
- Relational database (Wikipedia site. If you haven’t worked with relational databases, see this page for an introduction to relational database terminology and concepts. For an introduction to SQL Server in particular see Working with SQL Server databases later in this topic.)
- ASP.NET Data Access Options (MSDN. An introduction to data access options for ASP.NET and guidance on how to choose the ones that are appropriate for your scenario.)
Using the Entity Framework
- Entity Framework Development Approaches (MSDN. Guidance on how to choose an Entity Framework development approach Database First, Model First, or Code First.)
Using Entity Framework Code First
- Getting Started with EF 4.1 using MVC 3 (Covers a wide range of Entity Framework Code First scenarios but does not include Migrations.)
- Introduction to ASP.NET MVC 4 (Covers a narrow range of Entity Framework Code First scenarios but does include Migrations. For Migrations, see also Using Entity Framework Code First Migrations later in this topic.)
- Model Binding and Web Forms (tutorial series)
- Getting Started with ASP.NET 4.5 Web Forms - Introduction. (This tutorial set is not mainly about how to use Entity Framework but it includes tutorials that use Code First.)
- Entity Framework - Code First to an Existing Database (MSDN. Video and walkthrough that shows how to use Code First with an existing database.)
- Data Developer Center - Entity Framework (MSDN. For a guide to Entity Framework documentation that has been created and maintained by the Entity Framework team, see the Get Started link.)
See also Books about the Entity Framework and Additional Entity Framework Resources later in this topic.
Using Entity Framework Code First Migrations
- Introduction to ASP.NET MVC 4 - Adding a New Field to the Movie Model and Table
- ASP.NET Web Deployment using Visual Studio (Tutorial series that shows how to use Code First Migrations to deploy a database.)
- Data Developer Center - Code First Migrations (MSDN. The Entity Framework team’s Migrations documentation.)
- Web Deployment Overview for Visual Studio and ASP.NET (See the Configuring Database Deployment in Visual Studio section for an explanation of how Code First Migrations is integrated into Visual Studio web deployment features.)
Using Entity Framework Database First or Model First (the EF Designer)
For current resources on using the Entity Framework designer, see the MSDN Data Developer Center. See also the Books about the Entity Framework and Other Entity Framework resources sections later in this topic.
The following resources are older. They are useful if you want to use version 4.0 of the Entity Framework, and you want to use a data source control for data binding in a Web Forms application.
- Getting Started with the Entity Framework 4.0 (Shows how to use the EntityDataSource control.)
- Continuing with the Entity Framework (Shows how to use the ObjectDataSource Control. Includes a tutorial on concurrency handling, a tutorial on EF performance, and a tutorial on what's new in EF 4.0.)
Loading Related data in Entity Framework (Lazy Loading, Eager Loading, and Explicit Loading)
- Reading Related Data with the Entity Framework in an ASP.NET MVC Application (Code First, MVC sample application. The methods shown apply also to Web Forms model binding.)
- Data Developer Center - Loading Related Entities (MSDN. The Entity Framework team’s documentation about loading related data.)
Optimizing Entity Framework performance
- Advanced Entity Framework Scenarios for an ASP.NET Application (Shows how to execute your own SQL statements or call your own stored procedures, how to disable change detection, and how to disable validation when saving changes.)
- Performance Considerations for Entity Framework 5 (MSDN)
- Performance Considerations (Entity Framework) (MSDN)
- Maximizing Performance with the Entity Framework in an ASP.NET Web Application (Applies to Entity Framework 4.0.)
- See also Optimizing ASP.NET data access later in this topic.
Handling Concurrency in an Entity Framework Application
- Handling Concurrency with the Entity Framework in an ASP.NET MVC Application (Code First, DbContext API, using an MVC sample application.)
- Data Developer Center – Optimistic Concurrency Patterns (MSDN. The Entity Framework team’s concurrency documentation.)
- Handling Concurrency with the Entity Framework in an ASP.NET Web Application (Applies to Entity Framework 4.0. Database First, ObjectContext API, using a Web Forms sample application.)
Books about the Entity Framework
- Programming Entity Framework: DbContext by Julie Lerman and Rowan Miller
- Programming Entity Framework: Code First by Julie Lerman and Rowan Miller
Both of these books are up-to-date with the most current recommended techniques, and they provide a much more comprehensive yet easy-to-follow introduction to the Entity Framework than anything available on the Internet. Another book, Programming Entity Framework by Julie Lerman, is larger and more comprehensive but it is older and many of the techniques it covers are no longer the recommended way to use the Entity Framework. See also the list of books recommended by the Entity Framework team at Data Developer Center - Books on the MSDN site.
Other Entity Framework Resources
- Entity Framework (ADO.NET) team blog (One of the best resources for the most current information and announcements of new enhancements.)
- Julie Lerman's blog (Julie Lerman is the author and co-author of several Entity Framework books and courses, and her blog is another good source for current information and announcements.)
- MSDN Magazine (See the Data Points column, which is frequently about topics related to the Entity Framework.)
The following blogs are by members of the Entity Framework team at Microsoft. They are not as frequently updated as the team blog.
Data Binding in ASP.NET Web Forms Applications
Using Web Forms Model Binding
- Model Binding and Web Forms (tutorial series)
- Web Forms Model Binding Part 1: Selecting Data (Scott Guthrie's blog. In these older blog posts, the property that is currently named ItemType was named ModelType, but otherwise the information they contain is valid.)
- Web Forms Model Binding Part 2: Filtering Data (Scott Guthrie's blog)
- Web Forms Model Binding Part 3: Updating and Validation (Scott Guthrie's blog)
- ASP.NET 4.5 Web Forms Model Binding (video)
- Model Binding Part 1 - Selecting Data (video)
- Model Binding Part 2 - Filtering (video)
- Getting Started with ASP.NET 4.5 Web Forms - Display Data Items and Details
Using Web Forms Data Source Controls
Using Web Forms Data-Bound Controls and Data-Binding Expressions
- Model Binding and Web Forms (tutorial series)
- Getting Started with ASP.NET 4.5 Web Forms - Display Data Items and Details
- Strongly Typed Data Controls (Scott Guthrie's blog)
- Strongly Typed Data Controls (video)
- ASP.NET 4.5 Web Forms Strong Typed Data Controls (video)
- Data-Bound Web Server Controls (MSDN)
- Data-Binding Expressions Overview (MSDN. This page only covers Eval and Bind; it has not been updated to include Item and BindItem.)
Working with SQL Server Databases
- SQL Server Database Features (MSDN. For a general introduction to a wide variety of SQL Server topics, see the entries under this one in the TOC.)
- SQL Server Editions (MSDN. A summary of the available SQL Server editions, with links to more information about each one.)
- SQL Server Connection Strings for ASP.NET Web Applications (MSDN)
- Using SQL Server Compact for ASP.NET Web Applications (MSDN)
- Microsoft SQL Server: Database Product Samples (CodePlex site. Sample AdventureWorks databases.)
- Installing Sample Databases (CodePlex site. In addition to the methods shown here, you can also download one of the sample .mdf files to the App_Data folder of a web project, convert the database to LocalDB, and create a LocalDB connection string. For information about how to do that, see How to: Upgrade to LocalDB.)
See also the following sections on working with SQL Server Express and LocalDB, and choosing between SQL Server and SQL Database.
Working with SQL Server Express LocalDB Databases
- SQL Server Express 2012 LocalDB (MSDN. The official MSDN introduction to LocalDB.)
- SQL Server Connection Strings for ASP.NET Web Applications (MSDN)
- How to: Upgrade to LocalDB (MSDN. How to migrate an .mdf file from an earlier version of SQL Server Express to LocalDB. You also have to go through this process if you download one of the SQL Server 2012 sample databases.)
- Introducing LocalDB, an improved SQL Express (SQL Server Express blog. Has more background on why LocalDB was created than is included in MSDN.)
- LocalDB: Where is My Database? (SQL Server Express blog. Information about where LocalDB database files are created.)
- Using LocalDB with Full IIS, Part 1: User Profile (SQL Server Express blog. LocalDB is not designed to work with IIS. This series of blog posts explains the issues and some workarounds.)
Working with SQL Server Express Databases
- SQL Server Connection Strings for ASP.NET Web Applications (MSDN. If you use the AttachDBFileName connection string setting with SQL Server Express, see especially the User Instance section of this page.)
- How to take ownership of your local SQL Server Express 2008 (SQL Server Express blog. A common problem is not being able to work with SQL Server Express databases because you're not an administrator on the SQL Server Express instance. By default, only the person who installed SQL Server Express is an administrator. This blog explains how to make yourself a SQL Server Express administrator if you're an administrator on the computer.)
- Can my ASP.NET web application use a SQL Server Express database in production? (MSDN)
Working with Windows Azure SQL Database
- Deploy a Secure ASP.NET MVC app with Membership, OAuth, and SQL Database to a Windows Azure Web Site (WindowsAzure.com site)
- SQL Databases (WindowsAzure.com site. Getting started tutorials and how-to guides.)
- Windows Azure SQL Database (MSDN. The top-level node of the table of contents for SQL Database in MSDN.)
- Windows Azure SQL Database TechNet Wiki Articles Index (Microsoft TechNet site)
- Transient Fault Handling Application Block (A framework that enables you to handle transient network faults and connection errors that result from throttling. Available in a NuGet package: Enterprise Library 5.0 - Transient Fault Handling Application Block.)
- Getting Started with SQL Database and Entity Framework (MSDN)
- Windows Azure Training Kit (Microsoft Download Center. Includes hands-on labs for SQL Database.)
- Windows Azure SQL Database Community Forum
- Moving to Windows Azure SQL Database (MSDN. One chapter of a comprehensive end-to-end scenario by the Microsoft Patterns and Practices team. Covers why you might want to migrate and how to migrate from SQL Server to SQL Database.)
- Migrating SQL Server Databases to Windows Azure SQL Database (MSDN)
Choosing between SQL Server and Windows Azure SQL Database
- Compare SQL Server with Windows Azure SQL Database (Microsoft TechNet site)
- Data Migration to Windows Azure SQL Database: Tools and Techniques (MSDN. Includes sections that compare SQL Server to SQL Database and provide guidance on when to migrate from SQL Server to SQL Database.)
- Windows Azure SQL Database Delivery Guide (Microsoft TechNet site)
- SQL Server Feature Limitations (Windows Azure SQL Database) (MSDN)
- Windows Azure Table Storage and Windows Azure SQL Database - Compared and Contrasted (MSDN. For an application that you deploy to Windows Azure, Windows Azure Table storage might be an alternative to Windows Azure SQL Database. This topic helps you decide between these alternatives.)
- Windows Azure SQL Database (MSDN)
- Guidelines and Limitations (Windows Azure SQL Database)
Working with NoSQL Database Management Systems
- Windows Azure Data Services (WindowsAzure.com site. See the Table Service feature guide and the Big Data section of the page.)
Using LINQ Queries in ASP.NET Applications
- ASP.NET Data Access Options (MSDN. Includes an introduction to LINQ.)
- LINQ Training Videos (Joe Stagner's blog)
Using Dynamic Data Scaffolding
- Dynamic Data Project Templates (MSDN. Guidance on when to use Dynamic Data projects.)
- ASP.NET Dynamic Data (MSDN)
Securing Data Access
- Securing Data Access in ASP.NET (MSDN)
- Security Considerations (Entity Framework) (MSDN)
- How To: Secure Connection Strings when Using Data Source Controls (MSDN)
Optimizing Data Access Performance
- ASP.NET Performance Overview (MSDN)
- ASP.NET Caching (MSDN)
- Improving ASP.NET Performance (MSDN. There is a "Retired Content" warning at the top of this page, but most of the information is still relevant and there is no comparable updated resource.)
- Improving SQL Server Performance (MSDN. Same comment as the previous link.)
- See also Optimizing Entity Framework performance earlier in this topic.
Deploying a Database
Accessing Data through a Web Service
- Accessing Data through a Web Service (MSDN. Guidance on when to use Web API versus WCF.)
- Getting Started with ASP.NET Web API
- WCF Data Services (MSDN)
Additional Resources
- ASP.NET Data Access FAQ (MSDN)
- ASP.NET Web Forms Tutorials - Data (Most of these tutorials are relatively old; make sure you read ASP.NET Data Access Options first so that you don't get too far into a data access method that isn't right for your scenario.)
- ASP.NET MVC Overview - Data
- ASP.NET MVC 4 Content Map
- ASP.NET Web Pages Tutorials - Data
- Accessing Data in Visual Studio (MSDN. Provides a list of links similar to this content map but with a focus on Visual Studio rather than ASP.NET.)