oh yeah woo yeah
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Kehyeedra/Kehyeedra3/ApplicationDbContextFactory.cs

28 lines
929 B

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using Pomelo.EntityFrameworkCore.MySql.Infrastructure;
using Pomelo.EntityFrameworkCore.MySql.Storage;
using System;
using System.Collections.Generic;
using System.Text;
using dotenv.net;
using System.IO;
namespace Kehyeedra3
{
class ApplicationDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
{
public ApplicationDbContext CreateDbContext(string[] args = null)
{
DotEnv.Config(filePath: Path.Combine(AppContext.BaseDirectory, ".env"));
var optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
optionsBuilder.UseMySql(Environment.GetEnvironmentVariable("KEHYEEDRA_CONNSTR"),
x => { x.EnableRetryOnFailure(); x.CharSet(CharSet.Utf8Mb4); });
return new ApplicationDbContext(optionsBuilder.Options);
}
}
}