In order to start application you should start HttpApi.Host
project first, then start .Blazor
project
In order to log in to the system use this default credentials: Login - admin, password - 1q2w3E*
1. Switch to EF Core SQLite Provider:
https://docs.abp.io/en/abp/latest/Entity-Framework-Core-SQLite
For SQLite connection string use this pattern: "Filename=./MyDatabaseName.db", this pattern will create databases in
bin
folder of the project where migrations are executed
2. Separate host and identity data bases-
- Create db context and design time db factory for new database using this article
Don't forget to set attribute
ConnectionString
for your new db context. Make your db context look like in here
- Automate migration for second db context using this article
- Edit
OnModelCreating
method of your new db context so it looks like in this article - You can run
.DbMigrator
project now - Check
bin->Debug->net7.0
folder. Here you will find your new database
3. Make manipulations with host database
In previous step we separated host and identity databases. So let make a test migration to host database.
First of all put your database in this folder
.DbMigrator->bin->Debug->net7.0
Follow this steps:
-
Create simple class,
CustomerDemographics
you can find it here. -
Inside your
DbContext
for host database addDbSet
:
public DbSet<CustomerDemographics> CustomerDemographics { get; set; }
- Add this code in the
OnModelCreating
method ofDbContext
for host database:
builder.Entity<CustomerDemographics>(b =>
{
b.ToTable("CustomerDemographics");
b.HasKey(x => x.CustomerTypeId);
b.HasData(new CustomerDemographics() { CustomerTypeId = 1, CustomerDescription = "Lorem ipsum" });
});
- Add migration (I attach sample that works for my project, for your project use your db context name):
Please remember that you should run this command in directory where your db context is
dotnet ef migrations add AddCustomerDemographics --context OMSBlazorDbContext
-
Run db migrator
-
Now you can check changes in your host database
4. Add configuration for SQLite
In the OMSBlazorEntityFrameworkCoreModule
class of the .EntityFrameworkCore
project add this lines of code:
//This configuration is needed for sqlite
//https://github.com/abpframework/abp/issues/5661?ysclid=lhfcwt9oqb875559031
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
});
5. Add required connection strings
In appsettings.json
file of the .HttpApi.Host
project add this connection strings:
"Default": "Filename=./NorthwindSQLite.db",
"AbpIdentity": "Filename=./NorthwindIdentitySQLite.db",
"AbpFeatureManagement": "Filename=./NorthwindIdentitySQLite.db",
"AbpAuditLogging": "Filename=./NorthwindIdentitySQLite.db"
Default
- connection string is needed for connecting to the database where you store your Northwind
Why do we need other three connection strings(AbpIdentity
, AbpFeatureManagement
, AbpAuditLogging
)?
So this three connection strings are pointing to the database where tables for related module stored.
So for example in this current case tables for Identity, Feature, and Audit logging modules are stored in
NorthwindIdentitySQLite
database. If you don't write this connection strings ABP will try to find this tables
in the Default
connection string(this is how Abp works)
Tutorial of integration MudBlazor is here - https://github.com/yellow-dragon-cloud/AbpMudBlazor
Example of this service you can find here.
Discussion about this you can find here
In a nutshell: your service should implement
IRemoteService
- To .NET 8 migration notes:
- Add migration that add
AbpSettingDefinitions
table toNorthwindSQLite
1.1 To do this you can just create empty migration forOMSBlazorDbContext
and copy content of20240115220346_AddSettingsTable
(you can find this file on this path:OMSBlazor.EntityFrameworkCore
->Migrations
) - Add migration that add
LastPasswordChangeTime
column toAbpUsers
table inNorthwindIdentitySQLite
2.1 To do this you can just create empty migration forOMSBlazorIdentityDbContext
and copy content of20240116200534_AddLastPasswordChangeTimeColumn
(you can find this file on this path:OMSBlazor.EntityFrameworkCore
->OMSBlazorIdentity
) - Take instance of database that is now in
OMSBlazor.HttpApi.Host
and put it into thebin
folder of theOMSBlazor.DbMigrator
project and runOMSBlazor.DbMigrator
. This project will add new tables to the existing database - Copy back updated DBs to the
OMSBlazor.HttpApi.Host
There is a list of problems that you may encounter during publication. List of problems and theirs solutions
Solution: Turn on Load the user profile state on IIS
- On Plesk pannel of your domain you will find tab Hosting & DNS press it
- Then you will see Dedicated IIS Application pool for Website press
- There you will see checkbox - Load the user profile, check it
Solution: Go to class where you add OpenIddict
to your DI. In my case this is OMSBlazorHttpApiHostModule
and comment the line which adds dependency to the OpenIddict
.
[DependsOn(
...
//typeof(AbpAccountWebOpenIddictModule),
...
)]
public class OMSBlazorHttpApiHostModule : AbpModule
{
}