mirror of https://github.com/abpframework/abp.git
3 changed files with 93 additions and 0 deletions
@ -0,0 +1,31 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Design; |
||||
|
|
||||
|
namespace MyCompanyName.MyProjectName.Data; |
||||
|
|
||||
|
public class MyProjectNameDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameDbContext> |
||||
|
{ |
||||
|
public MyProjectNameDbContext CreateDbContext(string[] args) |
||||
|
{ |
||||
|
//<TEMPLATE-REMOVE IF-NOT='dbms:PostgreSQL'>
|
||||
|
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
||||
|
//</TEMPLATE-REMOVE>
|
||||
|
|
||||
|
var configuration = BuildConfiguration(); |
||||
|
|
||||
|
var builder = new DbContextOptionsBuilder<MyProjectNameDbContext>() |
||||
|
.UseSqlServer(configuration.GetConnectionString("Default")); |
||||
|
|
||||
|
return new MyProjectNameDbContext(builder.Options); |
||||
|
} |
||||
|
|
||||
|
private static IConfigurationRoot BuildConfiguration() |
||||
|
{ |
||||
|
var builder = new ConfigurationBuilder() |
||||
|
.SetBasePath(Directory.GetCurrentDirectory()) |
||||
|
.AddJsonFile("appsettings.json", optional: false); |
||||
|
|
||||
|
return builder.Build(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Design; |
||||
|
|
||||
|
namespace MyCompanyName.MyProjectName.Data; |
||||
|
|
||||
|
public class MyProjectNameDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameDbContext> |
||||
|
{ |
||||
|
public MyProjectNameDbContext CreateDbContext(string[] args) |
||||
|
{ |
||||
|
//<TEMPLATE-REMOVE IF-NOT='dbms:PostgreSQL'>
|
||||
|
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
||||
|
//</TEMPLATE-REMOVE>
|
||||
|
|
||||
|
var configuration = BuildConfiguration(); |
||||
|
|
||||
|
var builder = new DbContextOptionsBuilder<MyProjectNameDbContext>() |
||||
|
.UseSqlServer(configuration.GetConnectionString("Default")); |
||||
|
|
||||
|
return new MyProjectNameDbContext(builder.Options); |
||||
|
} |
||||
|
|
||||
|
private static IConfigurationRoot BuildConfiguration() |
||||
|
{ |
||||
|
var builder = new ConfigurationBuilder() |
||||
|
.SetBasePath(Directory.GetCurrentDirectory()) |
||||
|
.AddJsonFile("appsettings.json", optional: false); |
||||
|
|
||||
|
return builder.Build(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,31 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Microsoft.EntityFrameworkCore.Design; |
||||
|
|
||||
|
namespace MyCompanyName.MyProjectName.Data; |
||||
|
|
||||
|
public class MyProjectNameDbContextFactory : IDesignTimeDbContextFactory<MyProjectNameDbContext> |
||||
|
{ |
||||
|
public MyProjectNameDbContext CreateDbContext(string[] args) |
||||
|
{ |
||||
|
//<TEMPLATE-REMOVE IF-NOT='dbms:PostgreSQL'>
|
||||
|
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
||||
|
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true); |
||||
|
//</TEMPLATE-REMOVE>
|
||||
|
|
||||
|
var configuration = BuildConfiguration(); |
||||
|
|
||||
|
var builder = new DbContextOptionsBuilder<MyProjectNameDbContext>() |
||||
|
.UseSqlServer(configuration.GetConnectionString("Default")); |
||||
|
|
||||
|
return new MyProjectNameDbContext(builder.Options); |
||||
|
} |
||||
|
|
||||
|
private static IConfigurationRoot BuildConfiguration() |
||||
|
{ |
||||
|
var builder = new ConfigurationBuilder() |
||||
|
.SetBasePath(Directory.GetCurrentDirectory()) |
||||
|
.AddJsonFile("appsettings.json", optional: false); |
||||
|
|
||||
|
return builder.Build(); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue