Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In-app mode not working #13

Closed
ghost opened this issue Jul 18, 2017 · 4 comments
Closed

In-app mode not working #13

ghost opened this issue Jul 18, 2017 · 4 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Jul 18, 2017

I have an application on .NET 4.5.2, database is SQL Server 2016. MSBuild mode works just fine, but in-app mode is not working and an exception is not thrown.Here is the code I used to create the reference:

SqlConnection conn = new SqlConnection(WebConfiguration.sqlConnectionString);
var evolve = new Evolve.Evolve(conn, msg => Console.WriteLine(msg))
{
Locations = new List { "Migration_Scripts" },
Command = CommandOptions.Migrate,
MetadataTableName = "changelog",
Driver = "SqlClient",
SqlMigrationPrefix = "V",
SqlMigrationSeparator = "__",
SqlMigrationSuffix = ".sql",
PlaceholderPrefix = "${",
PlaceholderSuffix = "}"
};
try
{
evolve.Migrate();
}
catch (Exception ex)
{
}

@lecaillon lecaillon self-assigned this Jul 18, 2017
@lecaillon
Copy link
Owner

lecaillon commented Jul 18, 2017

Hi Catalin,

I think Evolve does not find the Migration_Scripts folder in in-app mode.
It works via MsBuild because the MsBuild task copy the Locations folders to the output folder for you. If you use Evolve directly you have 3 options:

  • Set the full path to your migration folder
  • Set the relative path to your migration folder from the output folder of your project
  • Use Visual Studio on each of your .sql file and modify the Copy to Output Directory property to Copy always

Don't hesitate to give me some feedback 😃

@ghost
Copy link
Author

ghost commented Jul 18, 2017

Hi Philippe,

Thank you for your quick response.I set the full path to the migration folder and it works.
I don't want to use the MsBuild and I removed the options from Web.config and the application only uses the In-app mode.
I've met another problem, when I add a new .sql file in Migration_Scripts I have to build the project and run the application to migrate the file, if I don't build the project the .sql file won't migrate.
Is there a way to migrate the file/s without building the project after I add a file in the migrations folder?

@lecaillon
Copy link
Owner

I don't reproduce your issue. I think you are struggling with your location path.
In your case, be sure to use the original Migration_Scripts folder, not the one Evolve build task will copy in your output folder.

@ghost
Copy link
Author

ghost commented Jul 19, 2017

Hi,

The problem was that I wanted to migrate the sql files in Application_Start method from Global.asax.cs.I needed to restart IIS and run the application again to solve this.I didn't pay attention to this detail.
Your migration tool is very useful and I am looking forward to use it.
Thank you for your quick responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant