I am trying to use FluentMigrator with PostgreSQL.
I have it running the migrations successfully, however the VersionInfo table is always in the public schema. I read on the FluentMigrator Wiki that I could override the schema name, but it is not working.
Here is my class that I wrote to override the settings:
namespace YARA.Migrations
{
using FluentMigrator.VersionTableInfo;
[VersionTableMetaData]
public class YaraVersionTable : DefaultVersionTableMetaData
{
public override string SchemaName
{
get { return "dbo"; }
}
public override string TableName
{
get
{
return "MigrationInfo";
}
}
}
}
And here is a screenshot of the db after running the migrations; with neither the schema or changing the table name taking effect for the VersionInfo table.
Thoughts?

You have to create your class, in my case:
[VersionTableMetaData]
public class CustomMetadataTable : DefaultVersionTableMetaData
{
public override string TableName => "__migrations_metadata";
}
Then add it to your services
var serviceProvider = new ServiceCollection()
.UseStandardConfiguration()
.AddFluentMigratorCore()
.ConfigureRunner(rb => rb
.AddPostgres92()
.WithGlobalConnectionString(c => c.GetService<IConfiguration>().GetConnectionString("THECONNECTION_STRING"))
.ScanIn(THEASSEMBLY).For.Migrations())
.AddLogging(lb => lb.AddFluentMigratorConsole())
.AddTransient<IVersionTableMetaData, CustomMetadataTable>()
.BuildServiceProvider(false);
Just make sure is the last thing you register (just right above the last line)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With