First, development background:
Since the old system has been unable to meet the actual business requirements, it is necessary to develop new projects even on existing databases.
Second, the difficulty point:
The EF is not allowed by default when you want to delete an existing database table and recreate it. When you create a database object, you are prompted to "an object named ' XXXXX ' already exists in the database"
Third, the solution:
1. Create test database.
2. Create database objects (within VS project).
3. Add the object to DbContext (Applicationdbcontext).
Public dbset< Database object class > object name {get;set;}
4. Add migrations using "DNX EF migrations Add XXX" within the Project console window
5. DNX EF Database Update to create the databases.
6. Copy the contents of the Applicationdbcontextmodelsnapshot.cs/migratonxxx.cs/migrationxxx.designer.cs to the file.
Iv. migrating database objects to the official database
1, modify the database connection "Appsettings.json=>connection" to the official database.
2. Use "Dnx EF migrations Remove" in the Project console window to remove the new migrations.
3. Add the Migratons content that has been copied to the system migration and ApplicationDbContextModelSnapshot.cs.
4. DNX EF Database Update.
V. EF7 has established a connection with the official database.
Entity framwork (EF) 7--developing MVC New project even on the database now