exam questions

Exam 70-487 All Questions

View all questions & answers for the 70-487 exam

Exam 70-487 topic 1 question 66 discussion

Actual exam question from Microsoft's 70-487
Question #: 66
Topic #: 1
[All 70-487 Questions]

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:

  • 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
Show Suggested Answer Hide Answer
Suggested Answer: CDE 🗳️
E: Run dotnet ef migrations add InitialCreate to scaffold a migration and create the initial set of tables for the model.
C: You can workaround some of the SQLite limitations by manually writing code in your migrations to perform a table rebuild. A table rebuild involves renaming the existing table, creating a new table, copying data to the new table, and dropping the old table.
D: SQLite does not support all migrations (schema changes) due to limitations in SQLite. For new development, consider dropping the database and creating a new one rather than using migrations when your model changes.
References:
https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
tiger25
Highly Voted 5 years, 2 months ago
EAC, not D. We don't need to drop all our database to modify only altered tables.
upvoted 18 times
derebaba
4 years, 12 months ago
Don't we need B to apply migrations?
upvoted 7 times
...
Dreamchaser1980
4 years, 7 months ago
For the lack of a better answer, I agree, should be ACE. 1) Run the following command: dotnet ef migrations add, creates a migration which can then be manually modified. 2) In general, you would first rename the tables affected by the migration. 3) Next create the tables affected by the migration, which contain the changes to the model. 4) Copy the data from the original tables(in step 2) to the new created tables (in step 3). 5) Drop the renamed tables from step 2. 6) Finally update the Database using dotnet ef database update.
upvoted 1 times
Dreamchaser1980
4 years, 7 months ago
See question #69 on https://www.examtopics.com/exams/microsoft/70-487/view/18/
upvoted 1 times
...
...
...
esend3
Highly Voted 5 years, 2 months ago
I think A C E are correct answers.
upvoted 7 times
...
piedro
Most Recent 4 years, 5 months ago
I dont like the answear ECD ... I dont think you can choose C und D together. You have to pick one of them. You either: 1 - drop the database and create the new one or 2 - writing code in your migrations to perform a table rebuild.... so that you dont drop the database and create it again. I think the corect answear is: EDB
upvoted 4 times
...
zimzimzimma
4 years, 7 months ago
Lots of confusion here. My primary answer was BCE, but after consideration I think it should be BDE because of the limitations of SQL Lite: https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations Since it is NOT specified what kind of changes are made to the model and one should RELIABLY handle the entity framework migration I think only way to do that is to drop and re-create the DB from scratch. So I think BDE is the correct answer. E,D,B, in that order.
upvoted 6 times
...
Dev666
4 years, 8 months ago
CABE as says "u must apply the changes to the database." and command todo so is "Update-Database: Executes the last migration file created by the Add-Migration command and applies changes to the database schema." . Link https://www.entityframeworktutorial.net/code-first/code-based-migration-in-code-first.aspx
upvoted 1 times
...
gfreeman
4 years, 9 months ago
CED are correct. Explanation for D is here: https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations "You can workaround some of these limitations by manually writing code in your migrations to perform a rebuild. Table rebuilds involve creating a new table, copying data to the new table, dropping the old table, renaming the new table. You will need to use the Sql(string) method to perform some of these steps."
upvoted 3 times
...
Phantasm
5 years, 1 month ago
E: Run dotnet ef migrations add InitialCreate to scaffold a migration and create the initial set of tables for the model. C: You can workaround some of the SQLite limitations by manually writing code in your migrations to perform a table rebuild. A table rebuild involves renaming the existing table, creating a new table, copying data to the new table, and dropping the old table. D: SQLite does not support all migrations (schema changes) due to limitations in SQLite. For new development, consider dropping the database and creating a new one rather than using migrations when your model changes.
upvoted 5 times
JftCoCo
4 years, 10 months ago
I think you don't need to drop the whole database for database migration.
upvoted 4 times
...
...
tiger25
5 years, 2 months ago
What about an existing tables? C option is creating new tables and after update-database it will be conflict.
upvoted 2 times
...
TinaZh
5 years, 3 months ago
I think that CEB 1) modify script to migration to create new table 2) dotnet ef migrations add <script> 3) dotnet ef database update https://docs.microsoft.com/en-us/ef/core/providers/sqlite/limitations#migrations-limitations-workaround https://docs.microsoft.com/ru-ru/ef/core/managing-schemas/migrations/?tabs=dotnet-core-cli#customize-migration-code
upvoted 3 times
tiger25
5 years, 2 months ago
What about an existing tables? C option is creating new tables and after update-database it will be conflict.
upvoted 3 times
...
Dev666
4 years, 8 months ago
CABE as says "u must apply the changes to the database." and command todo so is "Update-Database: Executes the last migration file created by the Add-Migration command and applies changes to the database schema." . Link https://www.entityframeworktutorial.net/code-first/code-based-migration-in-code-first.aspx
upvoted 1 times
KevinVording
4 years, 7 months ago
There's no answer to choose with the command "Update-Database". Only "dotnet ef database update". Which will not do anything.
upvoted 1 times
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago