955 B
955 B
Database initialization
You also need to initialize the data source with the tables from HopFrame.
Create a DbContext
-
Create a c# class that inherits from the
HopDbContextBaseand add a data source (In the example Sqlite is used)
IMPORTANT: You need to leave thebase.OnConfiguring(optionsBuilder)in place so the HopFrame model relations are set correctly.public class DatabaseContext : HopDbContextBase { protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { base.OnConfiguring(optionsBuilder); optionsBuilder.UseSqlite("..."); } } -
Register the
DatabaseContextas a servicebuilder.Services.AddDbContext<DatabaseContext>(); -
Create a database migration
dotnet ef migrations add Initial -
Apply the migration to the data source
dotnet ef database update