in the project, no matter which subsystem, the underlying framework uses a set of things, in the operation of the entity on the one hand is EF.
three questions to ask first
First, what is it?
Second, why use?
Third, how to use?
1.What is EF
EF ( Entity Framework ), is An object-relational mapper, enables. NET developers to workwith relational data using Domain-specific objects. E Ntity Framework allows youto create a model by writing code or using boxes and lines in the efdesigner.both of these Appro Aches can used to targe an existing database orcreate a new database.
Which meansEFis by tracking the change of the entity and generating the corresponding changes based on the mapping relationship and entitySQLscript and execute it into the database. In use.EFand then we all know thatEFThere are three modes, you can create a new database, or you can use the original database. But in the end it is the operation of the entity to manipulate the database, that is, the direct operation of the object is the entity. This also maps the changes to the changes in the database tables, which isORM. So what isORMit?
If someone asks you a question, what is an ORM, perhaps you can casually say object-relational mapping, English: Objectsrelational Mapping , or ORM for short . Let's take a picture to illustrate everything.
O is the object
R is the database relationship, you can say relational database tables
Mapping is a mapping that maps the operation of an object to a database table relationship. Implements the mapping of an object to a relational database.
The combination with our three-storey or familiar frame is the following. In the B - and U -Layers, we are object-oriented. When the information of the object changes, we need to keep the object's information in the relational database. With the ORM , we only need to manipulate the entities in the object. It can also be said that ORM is a middleware, the main implementation of program objects to relational database data mapping.
2.Why Useef
in LearningEFbefore, always before, when you develop an application, you may write a lot of data access layer code, used to read from the database object information, adding and removing some of the changes to the operation and so on. In theDALThe layers write a lot of methods to read the data, change the state of the statements, and the code has too many repetitions. For example, when we are in the engine room, we pass in an entity to useSQLCommandobject to add parameters, all properties should be mapped, setCommandTextproperty of the stored procedure, and then run theSQLCommand. Instead, each object repeats code like this, with the same query and update. A good way to do this is to have a mechanism for you to automatically generateDAL, and the weight of your relationship falls on the object. HappensEFis a framework that embodies this thought, which answers the second question at the beginning.
3.How touse It
since ef Yes orm and we also know ef There are three modes that we use in the project ef The teammate said a word, ef actually not difficult, followed by the code to understand, I also said, no matter how much the principle of doing it yourself, how to use in learning ef Three modes will be explained.
 
The whole article seems to be a narrative of what is orm, probably because the individual has a unique feeling for Orm , it is true that EF, is intended to reflect ORM thought. Small part just think ORM This kind of thought is very subtle, very avant-garde, the object-oriented thinking with the incisively and vividly, through a mapping relationship, all operations mapped past. This is a progress, an ideological progress. Later we no longer revolve around the database, but around the entity to turn.
The embodiment of Orm idea of "Itoo" EF Framework