With the Microsoft .NET Framework 3.5 comes new addition to the ADO.NET family – Entity Framework. The Entity Framework is a new modeling framework that enables developers to define a conceptual model of a database schema that closely aligns to a real world view of the information. It helps abstract the logical data schema into a conceptual model and allows for multiple ways to interact with the conceptual model through Object Services and a new data provider called EntityClient. The mission of EntityClient is to provide a gateway for entity-level queries. Through EntityClient one queries against a conceptual model, not against a specific store implementation of that model. EntityClient does not directly communicate with the data store but it requires a separate, store-specific, provider. An alternative to EntityClient is Object Services which help alleviate the amount of data-access code developers need to write. This article is a quick overview of the Entity Framework, its features and release date.
Entity Data Model
The Entity Data Model (EDM) is an entity-relationship (ER) model. The EDM defines data in a neutral format not constrained by the structure of programming languages or relational databases. EDM schemas are used to specify the details of entities and relationships and to implement them as data structures and these EDM schemes are specified in XML schemas using conceptual schema definition language (CSDL).
To read a complete EDM specification, visit http://msdn.microsoft.com/en-us/library/bb399281.aspx.
Entity SQL Language
Entity SQL is a SQL-like language provided by the ADO.NET Entity Framework to support the Entity Data Model (EDM). Entity SQL supports EDM constructs, enabling users to effectively query the data represented by an entity model.
The Entity Framework works with storage-specific data providers to translate generic Entity SQL into storage-specific queries. The EntityClient provider supplies a way to execute an Entity SQL command against an entity model and return rich types of data including scalar results, result sets, and object graphs. When you construct EntityCommand objects, you can specify a stored procedure name or the text of a query by assigning an Entity SQL query string to its System.Data.EntityClient.EntityCommand.CommandText property. The EntityDataReader exposes the results of executing an EntityCommand against an EDM.
In addition to the EntityClient provider, ObjectServices enables you to use Entity SQL to execute queries against an Entity Data Model and return data as strongly-typed CLR objects that are instances of entity types.
This is an example of Entity SQL use:
static void Main(string[] args) { using (EntityConnection conn = new EntityConnection("name=AdventureWorksEntities")) { conn.Open(); // Create a query. string esqlQuery = @" Select c.ContactID, c.SalesOrderHeader From AdventureWorksEntities.Contact as c"; // Create an EntityCommand. using (EntityCommand cmd = conn.CreateCommand()) { cmd.CommandText = esqlQuery; // Execute the command. using (EntityDataReader rdr = cmd.ExecuteReader(CommandBehavior.SequentialAccess)) { // Do something with the reader } } conn.Close(); } }
To learn more about Entity SQL language, open this link which redirects to Entity SQL reference topic. In addition, don’t miss the eSqlBlast application, the tool for writing entity SQL queries.
Object Services
Object Services is a component of the Entity Framework that enables you to query, insert, update, and delete data, expressed as strongly-typed CLR objects that are instances of entity types. Object Services supports both Language-Integrated Query (LINQ) and Entity SQL queries against types defined in an Entity Data Model (EDM). Object Services materializes returned data as objects, and propagates object changes back to the persisted data store. It also provides facilities for tracking changes, binding objects to controls, and handling concurrency. Object Services is implemented by classes in the System.Data.Objects and System.Data.Objects.DataClasses namespaces.
For more information about the ADO.NET Entity Framework, consider the following readings:
The Entity Framework will ship this summer with SP1 of VS 2008/.Net Framework 3.5. In the meanwhile, you can take a look at the .NET Framework SP1 beta, which includes Entity Framework.
2 Responses
D3nis
June 4th, 2008 at 07:55
1I like that, thanx.
Nedzad
June 4th, 2008 at 08:19
2Thank you very much. I’m glad to see that this blog is getting more attention.
RSS feed for comments on this post · TrackBack URI
Leave a reply
Categories
Archives
Links
Meta
Calendar