Entity Framework Migration Issue

I am currently using the community library step template (https://library.octopusdeploy.com/step-template/actiontemplate-run-entity-framework-migrations-(update-database)) to perform my Entity Framework migrations against MySQL databases, this has worked perfectly fine until we tried to promote our software to our production environment where I get the error

Executing: & “C:\Program Files\EntityFramework\tools\migrate.exe” “PC.Radix.Contract.DataContexts.EntityFramework.dll” /connectionString=“server=servername;database=contract;persistsecurityinfo=True;user id=myuser;password=mypassword;” /connectionProviderName=“System.Data.SqlClient” /startupConfigurationFile=“C:\Octopus\Applications\Production\PC.Radix.Contract.Service\0.0.6176.18602\web.config” /startUpDirectory=“C:\Octopus\Applications\Production\PC.Radix.Contract.Service\0.0.6176.18602\bin” /Verbose

System.Data.Entity.Core.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. —> MySql.Data.MySqlClient.MySqlException: Authentication to host ‘server’ for user ‘myuser’ using method ‘mysql_native_password’ failed with message: Access denied for user ‘myuser’@‘111.111.111.111’ (using password: YES) —> MySql.Data.MySqlClient.MySqlException: Access denied for user ‘myuser’@‘111.111.111.111’ (using password: YES)

However if i run the generated command in in elevated command prompt the migration completes successfully.

The only difference from our working environments and the production is the production environment is using MySQL running under Amazon RDS.

The operating system is Windows 2012 Server R2.

If anyone has any suggestions on this it would be most appreciated.

Regards,

Stuart Ferguson

Hi Stuart,

I have no specific knowledge of Amazon RDS, nor of Entity Framework.
However, stating the obvious based on your report, it would seem that the Octopus account executing that step doesn’t have the required permissions.

Are you executing the step on a Tentacle or on the Octopus Server (you can check the Run on field in the Step details)?

I would suggest executing it on a dedicated Tentacle, and configuring the account to be one with permissions to access your RDS database.

I hope that helps,
Michael

Hi Michael,

Thanks for the reply.

I have managed to get to the bottom of the issue and it was related to the way powershell was handling the password in the connection string.

The password was A!1bc$aa

I wasnt sure how to escape this in the powershell script so changed the password to not have any symbols in it.

Kind Regards,

Stuart

Ahh right, PowerShell escaping with the call operator can be tricky.

In this case, PowerShell is interpreting the $ as a variable. This StackOverflow question deals with a similar issue.

In any case, I’m glad to hear you found a work-around.