ok
continuous-integration/drone/push Build is passing Details

CI_DB_WORK
David D'ALMEIDA 1 year ago
parent 779a0cdd90
commit 23161b5a2c

@ -58,8 +58,9 @@ public class AppBootstrap(IConfiguration configuration)
Console.WriteLine("======================"); Console.WriteLine("======================");
Console.WriteLine($"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}"); Console.WriteLine($"server={HOST};port={PORT};database={DATABASE};user={USERNAME};password={PASSWORD}");
Console.WriteLine(connectionString); Console.WriteLine(connectionString);
services.AddDbContext<HeartTrackContext>(options =>
services.AddSingleton<IDataManager>( new DbDataManager(connectionString)); options.UseSqlite(connectionString), ServiceLifetime.Singleton);
services.AddSingleton<IDataManager>(provider => new DbDataManager(provider.GetRequiredService<HeartTrackContext>()));
break; break;
default: default:

@ -18,11 +18,8 @@ public partial class DbDataManager: IDataManager
DbContext = dbContext; DbContext = dbContext;
Console.WriteLine("Contexttttttttt"); Console.WriteLine("Contexttttttttt");
Console.WriteLine($"Database created Context: {DbContext.Database.EnsureCreated()}"); Console.WriteLine($"Database created Context: {DbContext.Database.EnsureCreated()}");
DbContext.Database.EnsureCreated();
Console.WriteLine($"Database created Context: {DbContext.Database.EnsureCreated()}");
ActivityRepo = new ActivityRepository(this); ActivityRepo = new ActivityRepository(this);
UserRepo = new UserRepository(this); UserRepo = new UserRepository(this);
DbContext.Database.EnsureCreated();
ActivityMapper.Reset(); ActivityMapper.Reset();
// Faire pour les autres reset() des autres mappers // Faire pour les autres reset() des autres mappers
} }
@ -30,14 +27,12 @@ public partial class DbDataManager: IDataManager
public DbDataManager(string dbPlatformPath) public DbDataManager(string dbPlatformPath)
: this(new HeartTrackContext(dbPlatformPath)) : this(new HeartTrackContext(dbPlatformPath))
{ {
DbContext.Database.EnsureCreated();
Console.WriteLine($"Database created String: {DbContext.Database.EnsureCreated()}"); } Console.WriteLine($"Database created String: {DbContext.Database.EnsureCreated()}"); }
public DbDataManager() public DbDataManager()
{ {
DbContext = new HeartTrackContext(); DbContext = new HeartTrackContext();
DbContext.Database.EnsureCreated();
Console.WriteLine($"Database created None: {DbContext.Database.EnsureCreated()}"); Console.WriteLine($"Database created None: {DbContext.Database.EnsureCreated()}");
ActivityRepo = new ActivityRepository(this); ActivityRepo = new ActivityRepository(this);
UserRepo= new UserRepository(this); UserRepo= new UserRepository(this);

Loading…
Cancel
Save