Database settings
The model
By default, the RecroGrid Framework generates a BaseDbContext class and uses it for database operations. It is recommended to derive the BaseDbContex from your own DbContext. Initialization of the database is necessary for the operation of the RecroGrid Framework, even if custom DbContext or database tables do not exist yet.
Configure ConnectionString
If ConnectionString does not exist yet, then add ConnectionString to appsettings.json
"ConnectionStrings": {
"SQLServer": "Server=(localdb)\\mssqllocaldb;Database=DATABASE_NAME;Trusted_Connection=True;MultipleActiveResultSets=false",
//"SQLServer": "Server=.\\SQLExpress;Database=DATABASE_NAME;Trusted_Connection=True;MultipleActiveResultSets=false",
//"SQLServer": "Server=SQLServer2019.lan,1433;Database=DATABASE_NAME;User ID=USER_NAME;Password=PASSWORD;MultipleActiveResultSets=false",
"PostgreSQL": "Host=192.168.5.115;Database=DATABASE_NAME;Username=USER_NAME;Password=PASSWORD;Command Timeout=15",
"Oracle21": "Data Source=Oracle21c:1521/xe;User Id=C##USER_NAME;Password=PASSWORD"
}
"Recrovit": {
"RecroGridFramework": {
"DefaultConnectionName": "SQLServer"
//"DefaultConnectionName": "PostgreSQL",
//"DefaultConnectionName": "Oracle21"
}
},
Initialize RecroGrid Framework database
Start the application and navigate to the /RGF/Admin page, then initialize the database.
After successful initialization, the system is capable of displaying all database tables on the Admin interface.
Related documentation:
Custom DbContext
It is recommended to derive the BaseDbContext from your own DbContext. However, if you prefer not to do this, you can disable the system from generating the BaseDbContext class.
<PropertyGroup>
<RGFBaseDbContext>false</RGFBaseDbContext>
</PropertyGroup>
When using a custom DbContext, you should also specify that type during service registration.
//builder.AddBaseDbContext();
builder.Services.AddDbContext<YourDbContext>(options =>
options.UseSqlServer(RGDataContext.DefaultConnectionString));
//app.UseRGF<BaseDbContext, BaseDbContextPool, BaseDbContextPool>();
app.UseRGF<YourDbContext>();
If you need more information on using the database, please refer to the Entity Framework documentation.
For an existing database, we recommend using the EF Core Power Tools (Visual Studio extension), which is capable of generating the model based on the database.