Developing Microsoft Azure and Web Services — Question 16
You are developing an ASP.NET Core web application by using an Entity Framework code-first approach. The application uses an Azure SQL Database. The code-first migration is configured to run as part of a continuous integration build.
You must add an Azure MySQL Database. This database must use the same schema as the existing Azure SQL Database instance.
You need to configure the migration to ensure that the existing TFS build definition remains unchanged.
What are two possible ways to achieve this goal? Each correct answer presents a complete solution.
Each correct selection is worth one point.
NOTE:
Answer options
- A. Use the ActiveProvider property to specify the provider to which the migration is applied.
- B. Create a new type that derives from DbContext and override the ActiveProvider object. Then, add or apply migrations using this type.
- C. Use the Entity Framework Core Fluent API to identify database providers.
- D. Create a separate Migration Assembly than the one containing the DbContext and switch the active provider during build.
Correct answer: B, C
Explanation
Option B is correct because creating a new class that extends DbContext allows for the customization of the ActiveProvider, enabling migrations to be directed to the appropriate database. Option C is also correct since the Fluent API can be used to identify and configure database providers effectively. Options A and D do not provide complete solutions for the specified requirements.