Let's talk about ORM first.
The following is a detailed and accurate description of the concepts found on the Internet.
Object/Relation Mapping (ORM) is generated with the development of object-oriented software development methods. Object-Oriented development is the mainstream development method in today's enterprise-level application development environment. Relational databases are the mainstream data storage systems that permanently store data in enterprise-level application environments. Objects and relational data are two forms of business entities. business entities are represented as objects in the memory and relational data in the database. Objects in the memory have associations and inheritance relationships. In the database, relational data cannot directly express many-to-many associations and inheritance relationships. Therefore, object-relational ing (ORM) systems generally exist in the form of middleware.ProgramMappings between objects and relational database data.
Object-Oriented development is based on the basic principles of Software Engineering (such as coupling, aggregation, and encapsulation), while relational databases are developed from mathematical theories, there are significant differences between the two sets of theories. To solve this mismatch, the object link ing technology emerged.
Let's start with O/R. The letter O originated from "object", while R came from "relational ). Objects and relational databases exist in almost all programs. In the business logic layer and user interface layer, We are object-oriented. When the object information changes, we need to save the object information in the relational database.
When you develop an application (do not use o/R Mapping), you may write a lot of data access layerCodeUsed to save, delete, and read object information from the database. You have written many methods in the Dal to read object data, change State objects, and so on. These codes are always repeated.
If you open your recent program and look at the Dal code, you will certainly see many similar general patterns. Let's take the method of saving objects as an example. You pass in an object, add sqlparameter to the sqlcommand object, map all attributes to the object, set the commandtext attribute of sqlcommand as the stored procedure, and then run sqlcommand. This code must be repeatedly written for each object.
In addition, is there a better way? Yes. Introduce an O/R Mapping. Essentially, an O/R Mapping will generate a dal for you. It is better to use o/R Mapping than to write the Dal code by yourself. You use o/R Mapping to save, delete, and read objects. O/R Mapping is responsible for generating SQL statements. You only need to care about objects.
The general ORM includes the following four parts:
An API for performing crud operations on persistent class objects;
A language or API is used to specify queries related to classes and class attributes;
A tool that specifies mapping metadata;
One technology allows the implementation of ORM to perform dirty checking, lazy Association fetching, and other optimization operations together with the transaction object.
(1) In a broad sense, Orm refers to the mutual conversion between the object-oriented object model and the data structure of the relational database.
(2) In a narrow sense, Orm can be considered as a virtual object-oriented data access interface based on relational database data storage. Ideally, based on such an object-oriented interface, persistence of an OO object requires no understanding of the Implementation Details of data stored in any relational database.
The following are my personal opinions, which are simple and practical.
I have been advocating Object-Oriented Programming for many years. Currently, data storage is a relational database instead of an object database. As a result, there is naturally a gap between programs and data. People who used to develop software, in addition to learningProgramming LanguageIn addition, you must also learn basic database operations, such as installing, starting, creating, and deleting databases, adding, deleting, and modifying database tables and data, as well as database stored procedures and functions, in addition, different databases, such as mainstream Oracle, SQL Server, MySQL, and DB2, bring a lot of extra things to be learned and mastered. The object relationship ing framework is generated as a result, you can automatically map the objects in the program to the storage in the database to isolate the details of the database storage. programmers can focus more on programming without understanding the details of the database.
Introduction to Entity Framework
I have heard of the well-known hibernate in the Java field before, and I know that there is an open source nhib.pdf transplanted to the net side. Microsoft has released its own ORM framework Entity Framework.
For more information about the Entity Framework, see the Introduction to the entity framewor topic of the blog.
The full name of Entity Framework is ADO. NET Entity Framework, which is an ORM (Object/relational mapping) framework developed by Microsoft Based on ADO. net.
Main features of Entity Framework:
1. Support for multiple databases (Microsoft SQL Server, Oracle, and DB2 );
2. The powerful ing engine can well support stored procedures;
3. Provides Visual Studio integrated tools for visual operations;
4. Excellent integration with ASP. NET, WPF, WCF, and WCF data services.