How to use custom version table meta data for new .net core FluentMigrator
See original GitHub issueI am migrating a pre .net core FluentMIgrator project to the new .net core version. I had a custom VersionTable that looked like this:
[VersionTableMetaData]
public class VersionTable : DefaultVersionTableMetaData
{
public override string TableName => "T_SCHEMA_VERSION_INFO";
}
This results in the following warning/error:
VersionTable.cs(9,5,18,6): error CS0618: 'DefaultVersionTableMetaData.DefaultVersionTableMetaData()' is obsolete: 'Use dependency injection'
I fixed this error by changing my code to this (removed attribute & added constructor):
public class VersionTable : DefaultVersionTableMetaData
{
public VersionTable(IConventionSet conventionSet, IOptions<RunnerOptions> runnerOptions)
: base(conventionSet, runnerOptions)
{
SchemaName = "distribution";
}
public override string TableName => "T_SCHEMA_VERSION_INFO";
}
This compiles correctly. But then, I don’t know what I have to add in my CreateServices
function:
return new ServiceCollection()
.AddFluentMigratorCore()
.ConfigureRunner(rb => rb
.AddMySql5()
.WithVersionTable(new VersionTable(???))
So the WithVersionTable
expects an instance of IVersionTableMetaData
. Unfortunately, I don’t know what to use for the convensionset
and runnerOptions
parameters.
Could you please provide some guidance and document them here? I have the feeling that this documentation is out of date.
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Custom metadata for the VersionInfo table
The custom IVersionTableMetaData is filtered by the values in the TypeFilterOptions. This allows different IVersionTableMetaData for every database. A common ...
Read more >c# - How to determine current version from VersionInfo for ...
I am using Fluent Migrator in .NET 6. I know that Fluent Migrator looks at VersionInfo table to determine which migrations need to...
Read more >Using fluentmigrator for automated database deployment (in ...
NET for data access, fluentmigrator is your answer to database migration ... In this video, I will walk through creating a database table, ......
Read more >How can I add information to the VersionInfo Table?
I'd like to add an extra column to the VersionInfo table to support generating ... /fluentmigrator/wiki/Create-custom-metadata-for-the-VersionInfo-table).
Read more >An effective database migration pattern for many instances ...
I'm using fluent migrator, and after some months or years, the number of migrations could be (and has been in previous projects) in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Or, IMHO, a more elegant option would be to add a
.WithVersionTable<VersionTable>()
function. The implementation of this function would be something simple like:What problem are you getting?