After learning to use MVC, I also started to get started with EF. I don't know much about the principles. I only know where to generate the model corresponding to the database after EF is installed, you do not need to write the model manually. Here we record how to generate a model in the project code from the created database. One is to record this operation method, and the other is to make it easier for cainiao like me to quickly generate a model. (I hope the heroes in the garden will give you some advice on the problem !)
Step 1: Install Entity Framework Power Tools Beta 4, open vs2013 -- tools -- Extensions and updates
Step 2: Select online on the left menu. In the search box on the top right, enter Entity Framework Power Tools Beta (4 here, I checked the latest version of 6.0 on Baidu, but I don't know what's going on)-click to download
Step 3: After the installation is complete, restart vs2013 -- Right-click the project -- select Entity Framework -- select reverse engineer code first
Step 4: As shown in the previous step, the "Connection Properties" window is displayed, and the database is installed locally. (Click). If you select the drop-down menu, you will regret it (very difficult) -- "select or enter the database name" Here select the database for which the model is to be generated -- click test connection to see if the connection is successful -- click OK
Step 5: As shown in, the model folder has generated the model corresponding to the table in your database (but the code in the mapping folder here is not very clear, only know that you can set the field attributes in the model, such as not empty, primary key, and unique)
Install and use Entity Framework power tool bate4 (code first) to automatically generate the corresponding model in the project from the existing data (newbie post, hope you can give some advice)