We are investigating using SCA to help with migrations in our EF Core 2.1 code-first project. The issue leading us to look at SCA is when deploying migrations to the target database using the CLI the dotnet tool needs access to the source code. E.g. https://documentation.red-gate.com/sca3/tutorials/worked-examples/work-with-entity-framework-codefirst-migrations I get errors when issuing the command below saying the command is unrecognised.
All the examples seem to be for EF6 and if I go through the code-first tutorial at
Comments
3 comments
-
Hi! This might be because the EF tools are not installed properly. Have you tried any of the suggestions in the following post:
https://stackoverflow.com/questions/9674983/the-term-update-database-is-not-recognized-as-the-name-of-a-cmdlet
-
Yes that did solve the error I quoted thanks, however the worked example has the command
Update-Database -Script -Source $InitialDatabase
That gives the error below.
<div>Update-Database : A parameter cannot be found that matches parameter name 'Script'.</div><div>At line:1 char:17</div><div>+ Update-Database -Script -Source $InitialDatabase</div><div>+ ~~~~~~~</div><div> + CategoryInfo : InvalidArgument: (:) [Update-Database], ParameterBindingExcep </div><div> tion</div><div> + FullyQualifiedErrorId : NamedParameterNotFound,Update-Database</div>
It seems that the Update-Database command is different between EF6 and EF Core -
You're right. It looks like the new command for generating the migration script in EF Core is Script-Migration
https://docs.microsoft.com/en-us/ef/core/miscellaneous/cli/powershell#script-migration
I haven't tried this myself but it looks like running Script-Migration -To InitialCreate should achieve the same result
Add comment
Please sign in to leave a comment.