27 lines
1.2 KiB
C#
27 lines
1.2 KiB
C#
|
|
using Microsoft.EntityFrameworkCore;
|
|||
|
|
using Microsoft.EntityFrameworkCore.Design;
|
|||
|
|
|
|||
|
|
namespace LMS.DAO
|
|||
|
|
{
|
|||
|
|
public class MyDbcontextDesignFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
|
|||
|
|
{
|
|||
|
|
//public MyDbcontextDesignFactory CreateDbContext(string[] args)
|
|||
|
|
//{
|
|||
|
|
// DbContextOptionsBuilder<ApplicationDbContext> optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
|
|||
|
|
// string str = Environment.GetEnvironmentVariable("CONNECTION_STRING");
|
|||
|
|
// optionsBuilder.UseMySql(str, ServerVersion.Parse("8.0.18-mysql"));
|
|||
|
|
// ApplicationDbContext db = new ApplicationDbContext(optionsBuilder.Options);
|
|||
|
|
// return db;
|
|||
|
|
//}
|
|||
|
|
|
|||
|
|
public ApplicationDbContext CreateDbContext(string[] args)
|
|||
|
|
{
|
|||
|
|
DbContextOptionsBuilder<ApplicationDbContext> optionsBuilder = new DbContextOptionsBuilder<ApplicationDbContext>();
|
|||
|
|
string str = "server=123.129.219.240;port=14080;user=luo;password=Luoqiang1405;database=LMS_TEST";
|
|||
|
|
optionsBuilder.UseMySql(str, ServerVersion.Parse("8.0.18-mysql"));
|
|||
|
|
ApplicationDbContext db = new ApplicationDbContext(optionsBuilder.Options);
|
|||
|
|
return db;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|