Files
HopFrame/docs/installation/Database.md

975 B

Database initialization

You also need to initialize the data source with the tables from HopFrame

Create a DbContext

  1. Create a c# class that inherits from the HopDbContextBase and add a data source (In the example Sqlite is used)

    public class DatabaseContext : HopDbContextBase {
       protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) {
           base.OnConfiguring(optionsBuilder);
    
           optionsBuilder.UseSqlite("...");
       }
    }
    

    IMPORTANT: You need to leave the base.OnConfiguring(optionsBuilder) in place so the HopFrame model relations are set correctly.

     

  2. Register the DatabaseContext as a service

    builder.Services.AddDbContext<DatabaseContext>();
    
  3. Create a database migration

    dotnet ef migrations add Initial
    
  4. Apply the migration to the data source

    dotnet ef database update