Reviewed-on: #2 Co-authored-by: Sergey Nazarov <insight.appdev@gmail.com> Co-committed-by: Sergey Nazarov <insight.appdev@gmail.com>
22 lines
827 B
C#
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);
|
|
}
|
|
} |