Developing Microsoft Azure and Web Services — Question 32
You are developing an ASP.NET Core web application by using an Entity Framework code-first approach. The application uses a SQLite database.
You make changes to the classes in the model. You must apply the changes to the database.
You need to suggest an approach to reliably handle the Entity Framework migrations.
Which three actions should you perform? Each correct answer presents a part of the solution.
Each correct selection is worth one point.
NOTE:
Answer options
- A. Modify the scaffolded migration script to drop the modified tables.
- B. Run the following command: dotnet ef database update
- C. Modify the scaffolded migration script to create new tables with the migration changes.
- D. Modify the scaffolded migration script to drop the existing database and create the new database.
- E. Run the following command: dotnet ef migrations add
Correct answer: C, D, E
Explanation
The correct answers C, D, and E are essential for applying model changes to the database. Option C allows the creation of new tables for the changes, D facilitates the removal and recreation of the database to incorporate the updates, and E initiates the migration process by adding the new changes. Options A and B are not suitable as A suggests dropping tables without creating new ones, and B simply updates the database without addressing the migration needs.