I added your codes, got a exception:
[11:23:24 FTL] Host terminated unexpectedly!
Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnPreApplicationInitializationModuleLifecycleContributor phase of the module XTC.License.LicenseAuthServerModule, XTC.License.AuthServer, Version=0.1.0.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating XTC.License.EntityFrameworkCore.AuthServerDbContext.. See the inner exception for details.
---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating XTC.License.EntityFrameworkCore.AuthServerDbContext.
---> Autofac.Core.DependencyResolutionException: None of the constructors found on type 'XTC.License.EntityFrameworkCore.AuthServerDbContext' can be invoked with the available services and parameters:
Cannot resolve parameter 'Microsoft.EntityFrameworkCore.DbContextOptions`1[XTC.License.EntityFrameworkCore.AuthServerDbContext] options' of constructor 'Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[XTC.License.EntityFrameworkCore.AuthServerDbContext])'.
See https://autofac.rtfd.io/help/no-constructors-bindable for more info.
at Autofac.Core.Activators.Reflection.ReflectionActivator.<>c__DisplayClass14_0.<UseSingleConstructorActivation>b__0(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Middleware.DelegateMiddleware.Execute(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context)
at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)
at Autofac.Core.Resolving.Pipeline.ResolvePipelineBuilder.<>c__DisplayClass14_0.<BuildPipeline>b__1(ResolveRequestContext context)
at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext context, Action`1 next)
So i modify the code to var dbContext = factory.CreateDbContext(null);
, like this:
public async override Task OnPreApplicationInitializationAsync(ApplicationInitializationContext context)
{
using var uow = context.ServiceProvider.GetRequiredService<IUnitOfWorkManager>().Begin();
{
var factory = new AuthServerDbContextFactory();
var dbContext = factory.CreateDbContext(null);
//var dbContext = await context.ServiceProvider.GetRequiredService<IDbContextProvider<AuthServerDbContext>>().GetDbContextAsync();
if ((await dbContext.Database.GetPendingMigrationsAsync()).Any())
{
await dbContext.Database.MigrateAsync();
}
await uow.CompleteAsync();
}
}
now everything is ok, is my modify right?
I try to update them to Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonX, but nothing found at nuget, only found LeptonXLite.
How to replace them ?
I Create a plugin with follow command:
abp new My.Plugin -t module
but i notice the .Web project use the Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared, and the .Web.Host, .Web.Unified, .AuthServer projects use the Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.
I try to update them to Volo.Abp.AspNetCore.Mvc.UI.Theme.LeptonX, but nothing found at nuget.
So how to change the UI of module to Pro(LeptonX)? or abp cli has a parameter to create pro like as abp new My.Plugin -t module-pro
?
I created a plugin with follow command:
abo new My.Plugin -t module
when i run AuthServer or Web.Unified,throw a exception, tip need create dataset. So i need run 'Update-Database' to create it.
My question is how to auto create database when plugin is run?
I found some document at https://abp.io/docs/latest/framework/architecture/modularity/plugin-modules, like this:
The Plugin may check if the database tables does exists and create the tables on the application startup or migrate them if the plug-in has been updated and requires some schema changes. You can use EF Core's migration API to do that.
But how to implement it,Is there a example?
Thanks~
Check the docs before asking a question: https://abp.io/docs/latest Check the samples to see the basic tasks: https://abp.io/docs/latest/samples The exact solution to your question may have been answered before, and please first use the search on the homepage. Provide us with the following info:
I created a project named as My.Platform with follow parameters
ABP Version: 8.2.2
UI framework: MVC
Theme: Lepton-X
Theme style: System
Mobile: None
Database provider: EFC
Database management system: MySQL
Connection string: Server=localhost;Port=3306;Database=XTC.BaaSo;Uid=root;Pwd=;
Public web site: Yes
Cms-Kit: Yes
Separate tenant schema: Yes
Tiered: Yes
and i created a project named as My.Plugin with follow command
abp new My.Plugin -t module
then i direct build the My.Plugin, got some files. i load them at My.Platform.HttpApi.Host/Program.cs like this:
......
builder.Host
.AddAppSettingsSecretsJson()
.UseAutofac()
.UseSerilog();
await builder.AddApplicationAsync<BaaSoHttpApiHostModule>(_options =>
{
var configuration = _options.Services.GetConfiguration();
var businessUnitsPath = configuration["BusinessUnits:Path"];
if (businessUnitsPath.IsNullOrWhiteSpace())
{
throw new AbpException("the BusinessUnits is null or empty!");
}
businessUnitsPath = Environment.ExpandEnvironmentVariables(businessUnitsPath);
if (!Directory.Exists(businessUnitsPath))
{
throw new AbpException($"BusinessUnitsPath:{businessUnitsPath} not found!");
}
var files = new List<string>();
foreach (var file in Directory.GetFiles(businessUnitsPath))
{
Log.Information($"Found a BusinessUnit: {Path.GetFileName(file)}");
files.Add(file);
}
_options.PlugInSources.AddFiles(files.ToArray());
});
var app = builder.Build();
......
Is this the right thing to do? and how put the api of My.Plugin to another definition at page of swagger(now all in a same definition)
Yes, I need this, Thank you ~~
OK,
I want to modify this url, replace some parameters and sign it.
Hi,
My web will redirect to the login page if not authenticated.
Web/Pages/Index.html
public class IndexModel : AbpPageModel
{
public ActionResult OnGet()
{
if (Request.Query["ex"] == "yes")
{
throw new DivideByZeroException("This is a test exception!");
}
if (!CurrentUser.IsAuthenticated)
{
return Redirect("~/Account/Login");
}
else
{
return Page();
}
}
}
and it open this url
http://auth.mydomain.com/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%3Fclient_id%3DWeb%26redirect_uri%3Dhttp%253A%252F%252Fconsole.mydomain.com%252Fsignin-oidc%26response_type%3Dcode%2520id_token%26scope%3Dopenid%2520profile%2520roles%2520email%2520phone%2520AccountService%2520IdentityService%2520AdministrationService%2520SaasService%2520CmsService%2520BusinessUnit%26response_mode%3Dform_post%26nonce%3D638332667736323954........mJlMThjN2EyYWE0%26state%3DCfDJ8Eld3tn4Rn1GjnZqhM-ZUBhwOYwgPtXiFM1D3kL1WtTfijdvGsvbYNVPJtv6A0gw4zpSJDK-IVFZgg6EzByFk_PNFmgyv3oJ.......P7AmgWMDl3GtjG_c1V_06gxU06E_%26x-client-SKU%3DID_NET6_0%26x-client-ver%3D6.15.1.0
Can I construct this url myself?
By the way, I use the microservice-pro template.
Hi,
My web will redirect to the login page if not authenticated.
Web/Pages/Index.html
public class IndexModel : AbpPageModel
{
public ActionResult OnGet()
{
if (Request.Query["ex"] == "yes")
{
throw new DivideByZeroException("This is a test exception!");
}
if (!CurrentUser.IsAuthenticated)
{
return Redirect("~/Account/Login");
}
else
{
return Page();
}
}
}
and it open this url
http://auth.mydomain.com/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%3Fclient_id%3DWeb%26redirect_uri%3Dhttp%253A%252F%252Fconsole.mydomain.com%252Fsignin-oidc%26response_type%3Dcode%2520id_token%26scope%3Dopenid%2520profile%2520roles%2520email%2520phone%2520AccountService%2520IdentityService%2520AdministrationService%2520SaasService%2520CmsService%2520BusinessUnit%26response_mode%3Dform_post%26nonce%3D638332667736323954........mJlMThjN2EyYWE0%26state%3DCfDJ8Eld3tn4Rn1GjnZqhM-ZUBhwOYwgPtXiFM1D3kL1WtTfijdvGsvbYNVPJtv6A0gw4zpSJDK-IVFZgg6EzByFk_PNFmgyv3oJ.......P7AmgWMDl3GtjG_c1V_06gxU06E_%26x-client-SKU%3DID_NET6_0%26x-client-ver%3D6.15.1.0
Can I construct this url myself?
By the way, I use the microservice-pro template.
Hi,
My web will redirect to the login page if not authenticated.
Web/Pages/Index.html
public class IndexModel : AbpPageModel
{
public ActionResult OnGet()
{
if (Request.Query["ex"] == "yes")
{
throw new DivideByZeroException("This is a test exception!");
}
if (!CurrentUser.IsAuthenticated)
{
return Redirect("~/Account/Login");
}
else
{
return Page();
}
}
}
and it open this url
http://auth.mydomain.com/Account/Login?ReturnUrl=%2Fconnect%2Fauthorize%3Fclient_id%3DWeb%26redirect_uri%3Dhttp%253A%252F%252Fconsole.mydomain.com%252Fsignin-oidc%26response_type%3Dcode%2520id_token%26scope%3Dopenid%2520profile%2520roles%2520email%2520phone%2520AccountService%2520IdentityService%2520AdministrationService%2520SaasService%2520CmsService%2520BusinessUnit%26response_mode%3Dform_post%26nonce%3D638332667736323954........mJlMThjN2EyYWE0%26state%3DCfDJ8Eld3tn4Rn1GjnZqhM-ZUBhwOYwgPtXiFM1D3kL1WtTfijdvGsvbYNVPJtv6A0gw4zpSJDK-IVFZgg6EzByFk_PNFmgyv3oJ.......P7AmgWMDl3GtjG_c1V_06gxU06E_%26x-client-SKU%3DID_NET6_0%26x-client-ver%3D6.15.1.0
Can I construct this url myself?
By the way, I use the microservice-pro template.