EF framework to access database access entry

Always wanted to see this part, today finally see.

vs2017 debugging through.

Recorded as follows:

1, add the provider needed, add a little drive means. Right-click the project, NUGET

  

  "Browse", "JetEntityFrameworkProvider", installation, as

  

  After the completion of the configuration file (console app.config) will be in the driver:

The best attribute of the project to generate tune into "x86", vs will warn you of this drive is 32.

2, the database is given an absolute path in the configuration file:

Built databases, tables do not build

3, can create new models folder (the Model), which was added in an Entity Data Model, as shown:

  

  The following diagram here I chose the third (several other plans you have time take a look)

 

After completion of a model1.cs, substantially follows (1 or 2 do not tangle, FIG 2 is a rear grip)

4, according to the need to modify the model, the results of my action as follows:

Description: t1 represent each record of the table (No. Name Age), T1s represents goes called "t1" of the table, the program through brown "name ...." part of the configuration file to find the information, according to the drive and file path to the operating table, Model1 represent your database. This, what else you want to modify, you can fly along.

5, the frame used in the program ef programming, the most simple example below:

Reminder: Do not forget using. firstordefault will not go with the next set of knowledge. By the way, the first run will not say the database data. This will give you time table built, add your own data into just fine. As shown below:

vs _mig .... that figure is automatically added to the list, too lazy to ignore it.

operation result:

CRUD lot of information online, here a little.

Guess you like

Origin www.cnblogs.com/wanjinliu/p/11072744.html