text-matcher/src/Nocr.TextMatcher.Persistence/DesignTimeTextMatcherContextFactory.cs
Sergey Nazarov ced8c15efb DRAFT: nazarovsa/persistence (#2)
Reviewed-on: #2
Co-authored-by: Sergey Nazarov <insight.appdev@gmail.com>
Co-committed-by: Sergey Nazarov <insight.appdev@gmail.com>
2024-03-29 13:24:04 +00:00

22 lines
827 B
C#

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.Extensions.Configuration;
namespace Nocr.TextMatcher.Persistence;
public class DesignTimeTextMatcherContextFactory : IDesignTimeDbContextFactory<TextMatcherContext>
{
public TextMatcherContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<TextMatcherContext>();
var configuration = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.Build();
var connectionString = configuration.GetConnectionString("MariaLocal");
optionsBuilder.UseMySql(connectionString,
new MariaDbServerVersion(MariaDbServerVersion.LatestSupportedServerVersion));
return new TextMatcherContext(optionsBuilder.Options);
}
}