In-Depth

.NET Survival Guide: Data Access Technologies

BACK TO .NET SURVIVAL GUIDE

Data Access Technologies
The frequency with which Microsoft has changed database access technologies is remarkable, with each new scheme offering the promise that .NET developers have finally arrived at a long-term solution. The core problem with the .NET Framework was that although there was a strong database access technology provider in ADO.NET, it failed to deal with the key pain point for developers: object-relational mapping (ORM). Specifically, how the data represented in an object-oriented programming language such as C# or Visual Basic .NET serializes into a relational database. Although there were numerous solutions available in 2007, none truly dealt with the problem of eliminating the need for SQL and of SQL schema seeping into the client-side programming language.

Tool Box

  • ADO.NET
  • LINQ to SQL
  • Entity Framework
  • NHibernate
  • LLBLGen Pro

Visual Studio 2008 and the .NET Framework 3.0 changed this situation radically. For the first time mainstream .NET development had a superb mechanism, in the form of LINQ, for programming the object-relational impedance mismatch. Although Visual Studio 2008 presented two database LINQ solutions -- LINQ to SQL and the Entity Framework -- Visual Studio 2010 addressed this ambiguity with the Entity Framework 4. Microsoft has essentially deprecated LINQ to SQL. Though Prominent ORM alternatives exist in NHibernate and LLBLGen Pro, the Entity Framework 4 has emerged as the most logical data access target for .NET developers. This leaves developers with four prudent options when developing under the .NET Framework 4:

  • Leave existing development on LINQ to SQL but search for an opportunity to migrate to the Entity Framework.
  • Leave ADO.NET development in place, but capitalize on any opportunities to implement with the Entity Framework.
  • Commit to using the Entity Framework by default for database-access development going forward, outside of exceptional cases.
  • Consider widely deployed alternatives like NHibernate and LLBLGen Pro, which boast features and support that rival those of the ORM technologies coming from Microsoft. Prior to the .NET Framework 4, gaps in the first version of the Entity Framework made it a less-than-perfect solution. Microsoft has resolved many of those shortcomings with the Entity Framework 4. Among the significant new features making the Entity Framework 4 a credible data access target:
  • Foreign Key properties on entities allow for accessing data associated with foreign key relationships.
  • Plain Old CLR Objects (POCO) can be generated, using online templates, so that no special entity framework derivation or attribution is required.
  • Text Template Transformation Toolkit (T4) Code Generation enables deep customization of the entities that are generated from the database, and the ability to even generate the database given a set of POCO objects.
  • Lazy Loading, enabled by default, doesn't load an entire object or its graph until the code actually uses it.
  • Improved stored-procedure support, which is accessed through member functions on an entity, allows for such features as returning complex types from stored procedures.
  • Enhanced support for entities that are disconnected from the Entity Framework context and possibly transferred across WCF boundaries -- even with support for change tracking within the entity.
  • Inclusion of interfaces like IObjectSet that enable the development of mock data layers.

These new features, all of which are very significant to the vast majority of database development scenarios, provide a compelling narrative for the Entity Framework 4. In addition, Microsoft continues to provide interim community technology previews of future enhancements slated for the Entity Framework.

In Summary
After some fits and starts, Microsoft has landed on a viable target for .NET data access in the form of Entity Framework 4.

About the Author

Mark Michaelis (http://IntelliTect.com/Mark) is the founder of IntelliTect and serves as the Chief Technical Architect and Trainer. Since 1996, he has been a Microsoft MVP for C#, Visual Studio Team System, and the Windows SDK and in 2007 he was recognized as a Microsoft Regional Director. He also serves on several Microsoft software design review teams, including C#, the Connected Systems Division, and VSTS. Mark speaks at developer conferences and has written numerous articles and books - Essential C# 5.0 is his most recent. Mark holds a Bachelor of Arts in Philosophy from the University of Illinois and a Masters in Computer Science from the Illinois Institute of Technology. When not bonding with his computer, Mark is busy with his family or training for another triathlon (having completed the Ironman in 2008). Mark lives in Spokane, Washington, with his wife Elisabeth and three children, Benjamin, Hanna and Abigail.

comments powered by Disqus

Featured

  • See Prompts Microsoft Engineers Use for Bleeding-Edge Multimodal RAG AI Research

    Vision-centric queries show how front-line experts are prompting LLMs these days.

  • AI Explains Expressions in Update to Java on VS Code

    "The Spring Tools now show code lenses above these expressions that allow you to quickly let GitHub Copilot explain those statements for you."

  • Microsoft Eases Integration with Semantic Kernel AI SDK

    The basic idea is to provide unified API abstractions, especially for idiomatic C# code, to help platform developers and others work with any provider with standard implementations for caching, telemetry, tool calling and other common tasks.

  • Final .NET 9 Preview Ships with Go-Live License

    Visual Studio developers can now download the SDK for .NET 9 Release Candidate 2 with a go-live license, meaning devs get Microsoft support for production applications even before the framework reaches general availability next month.

Subscribe on YouTube