ADO.NET Entity Framework is an
Object/Relational Mapping (ORM) framework that enables developers to
work with relational database. It enabling developers to deal with data
as objects and properties.Using the Entity Framework, developers issue
queries using LINQ, then retrieve and manipulate data as strongly typed
objects using C# or VB.Net.
The Entity Framework’s ORM
implementation also provides services like change tracking, identity
resolution, lazy loading, and query translation so that developers can
focus on their application-specific business logic rather than the data
access fundamentals. ADO.NET Entity Framework is targeted for developing
Enterprise applications which can support MS SQL databases as well as
other databases like as Oracle, DB2, MySql and many more. To learn
entity framework first we need to know what is orm. What is ORM?
ORM is an acronym that stands for object/relational mapping. Basically, an ORM framework is used to persist model objects in a relational database and retrieve them. It uses metadata information to interface with the database. This way, your data-layer code knows nothing about the database structure. The ORM tool becomes middleware that completely hides the complexity.
The heart of ORM is the mapping—the mapping technique is what binds the object and relational worlds. By mapping, you express how a class and its properties are related to one or more tables in the database. This information is used by the ORM tool’s engine to dynamically build SQL code that retrieves data and transforms it into objects. Similarly, by tracking changes to objects’ properties, it can use mapping data to send updates back to the database. The mapping information is generally expressed as an XML file. As an alternative, some ORM tools use attributes on the classes and their properties to maintain mapping data.
Advantage of Entity Framework
Productivity
Entity Framework can take up to 35 percent of the entire application code. It make the developer’s life easier than ever. In spite of its limitations, the designer integrated into Visual Studio dramatically simplifies the mapping process.Maintainability
Since you have the fewer lines of code to fetch data from database,the fewer lines of code you have to maintain. This is particularly true in the big projects.Performance
The complexity of ORM introduces an obvious slowdown in performance. In entity framework first request to fetch data is little bit slow but after that is fast to fetch data from database.
EF Version Introduced Features EF 3.5 Basic O/RM support with Database First approach. EF 4.0 POCO Support, Lazy loading, testability improvements, customizable code generation and the Model First approach. EF 4.1 First to available in the NuGet, Simplified DBContext API over ObjectContext, Code First approach. EF 4.1.1 patch released with bug fixing of 4.1. EF 4.3 Code First Migrations feature that allows a database created by Code First to be incrementally changed as your Code First model evolves. EF 4.3.1 patch released with bug fixing of EF 4.3. EF 5.0 Announced EF as Open Source. Introduced Enum support, table-valued functions, spatial data types, multiple-diagrams per model, coloring of shapes on the design surface and batch import of stored procedures, EF Power Tools and various performance improvements. EF 6.0 - Current release EF 6.0/6.1 is the latest release of Entity Framework. It includes many new features related to Code First & EF designer like asynchronous query & save, connection Resiliency, dependency resolution etc.
Entity Framework Models
Microsoft’s Entity Framework evolved from a methodology known as Entity Relationship Modeling (ERM). An ERM defines a schema of entities and their relationships with one another. Entities are not the same as objects. Entities define the schema of an object, but not its behavior. So, an entity is something like the schema of a table in your database, except that it describes the schema of your business objects. There are three models in the entity framework:CONCEPTUAL MODEL
The conceptual model is where you describe the model classes. This file is split into two main sections: the first is a container that lists all the entities and the relationships that are managed by Entity Framework, and the second contains a detailed description of their structure.STORAGE MODEL
The storage model is the equivalent of the conceptual model, but it describes the database organization. Not only is this file conceptually similar to the previous one, but it also uses the same XML nodes. Unlike the conceptual model, it isn’t possible to split this model into several physical files. The first section of this file lists all the tables, views, stored procedures, and foreign keys that are affected. The second section describes the items listed in the first node.
Regarding tables and views, the columns and primary keys are described. When it comes to stored procedures, input and output parameters are described. The description of a foreign key contains information about the table involved, the cardinality, and the delete and update rules.MAPPING MODEL
The mapping file is completely different. Its job isn’t to describe something but to compensate for the differences that exist between the two previous models. This is where the real magic of mapping happens: you map a class to one or multiple tables, map one table to one or multiple classes, define inheritance mapping, and map stored procedures for both updates and object retrieval.
There is only one important node in this file: it associates the class to a table and can be repeated more than once to ensure that a class can be mapped against multiple tables, and vice versa. Like the storage description file and unlike the conceptual file, the mapping file can’t be split into multiple files.
Post a Comment