Databases Reference
In-Depth Information
Metadata in Entity Framework and Dynamic Data
The generated NorthwindEntities class inherits from the ObjectContext base class
provided by Entity Framework. This class, as well as its LINQ to SQL counterpart,
DataContext , provides access to rich metadata describing all tables in the data model,
including their names, columns, data types, associations, and more. Although both LINQ
to SQL and Entity Framework offer similar types of metadata, they use different APIs to
represent it. Dynamic Data encapsulates these differences, provides a single metadata API
that works for both of these frameworks, and extends it with presentation metadata, such
as display labels and validation error messages.
Rich metadata API enables Dynamic Data web applications to generate user interface
elements such as data entry fields, forms, and entire pages at runtime, all based on the
definitions derived from the database and extended by the developer. However, before the
web application can access this metadata, the data context class needs to be registered in
the application Global.asax file as in Listing 1.4.
LISTING 1.4
Registering Data Model with Dynamic Data in Global.asax.cs
using System;
using System.Data.Entity;
using System.Web.DynamicData;
using DataModel;
namespace WebApplication
{
public class Global : System.Web.HttpApplication
{
public static readonly MetaModel DefaultModel = new MetaModel();
void Application_Start(object sender, EventArgs e)
{
DefaultModel.RegisterContext(typeof(NorthwindEntities));
}
}
}
 
 
Search WWH ::




Custom Search