EF preliminary understanding, EF understanding
EF stands for ADO. NET Entity Framework. It is an object-link solution developed by Microsoft Based on ADO. NET. Here, the object ing relationship is the program design model and database. EF integrates the two, so that the program designer can operate the database without understanding SQL commands.
I have a preliminary understanding of EF. I think this stuff is too powerful. I remember Jia Lin said a few days ago that a software should improve user experience. This includes not only software users, but also software developers, with EF, we have to say that the experience of developers has greatly improved.
The following example shows how to use EF to generate a database.
1. Create a project in VS. The project type is [console application] and the project name is P01FirstEF.
2. In the new project, right-click → add new item, select "ADO. NET Object Data Model" under the "data" menu, and name it.
3. After adding the object data model, you can add "entity" and "Contact. Right-click on. edmx → add → object, and name the Object User.
4. Add attributes to the object. Right-click the object and choose scalar attribute to add attributes to the object.
5. After adding multiple entities, if there is a link between the entities, you can also add foreign key constraints to the entities.
6. Of course, you can also add links between entities. In the blank area, right-click → add → join, and select ing between entities.
7. finally, the database is generated. In the blank section, right-click → generate a database based on the model. Then, the SQL statement for database table creation is automatically generated for us, we only need to create a new database in SQL Server, copy the generated SQL language, and execute it directly.
Conclusion: we feel that the technologies we are learning are moving towards improving efficiency and simplicity. In addition to the ability to generate databases based on the design model, EF can also use the data entity model to directly access the database that has been created, and add the LINQ statement, greatly reducing the workload of our development work.