Starts in:
2 DAYS
10 HRS
59 MIN
33 SEC
Starts in:
2 D
10 H
59 M
33 S

Activities of "hansmogren"

Thanks, we'll look into that. Is there no way to add extra fields to the token error response?

We would like our front-end to be able to determine why the user was unable to authenticate and display the appropriate message, e.g. to send an email confirmation token if the email has not been verified.

Answer

Thank you for answering.

Answer

Any update on the AppService plural names issue with ABP Suite?

After my test, the following code is ok.

Sorry, but I get System.InvalidOperationException: 'Unable to resolve service for type 'MyProjectName.IMyEntityRepository' while attempting to activate 'MyProjectName.BeforeSaveTrigger'.' doing it this way as well.

hi hansmogren

You should use MyProjectNameMigrationsDbContext in CreateDatabaseAndGetConnection method.

Ok! I don't understand why the migrations context is used for testing, but anyway :)

I'm using the free template, What is your app type? tiered or separate-tenant-schema?

My solution is based on the commercial startup template. It's a monolith, not tiered, and no separate tenants.

c.DbContextOptions.UseTriggers(t => 
{ 
    t.UseApplicationScopedServiceProviderAccessor(_ => _.GetRequiredService<IHttpContextAccessor>().HttpContext?.RequestServices); 
}); 

Doing this way I get System.InvalidOperationException: 'No service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' has been registered.' on application start.

Thanks, that change made the trigger be registered and triggered.

However the dependency injection failed while instantiating my trigger class. I am injecting an IRepository into it and got an exception: System.InvalidOperationException: 'Unable to resolve service for type 'MyProjectName.IMyEntityRepository' while attempting to activate 'MyProjectName.BeforeSaveTrigger'.'

I solved this by including the line t.UseApplicationScopedServiceProviderAccessor(_ => context.Services.GetServiceProviderOrNull()); as below since the the documentation at https://github.com/koenbeuk/EntityFrameworkCore.Triggered/wiki/Dependency-injection mentions this solution:

Configure a method that returns the current relevant ServiceProvider. This can be done by providing a method through: triggerOptions.UseApplicationScopedServiceProviderAccessor(sp => ...). The first argument will be either the application ServiceProvider if available or otherwise the internal service provider.

Does this seem like a reasonable solution or will it break something?

            options.Configure(c =>
            {
                c.UseSqlServer();
                c.DbContextOptions.UseTriggers(t =>
                {
                    t.UseApplicationScopedServiceProviderAccessor(_ => context.Services.GetServiceProviderOrNull());
                    t.AddTrigger&lt;BeforeSaveTrigger&gt;();
                });
            });

hi @all

https://github.com/abpframework/abp/commit/b73f9e2c6e91251f800d5aa3a00b1edf516ed933

Thanks,

After trying this I get this error when running the unit test:

Volo.Abp.AbpInitializationException : An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module MyProject.MyProjectTestBaseModule, MyProject.TestBase, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null: SQLite Error 1: 'no such table: AbpSettings'.. See the inner exception for details.
---- Microsoft.Data.Sqlite.SqliteException : SQLite Error 1: 'no such table: AbpSettings'.

And what about MyProjectNameEntityFrameworkCoreTestModule.CreateDatabaseAndGetConnection? Should it use the MyProjectNameMigrationsDbContext, not the new TestDbContext?

private static SqliteConnection CreateDatabaseAndGetConnection()
{
    var connection = new SqliteConnection("Data Source=:memory:");
    connection.Open();
    var options = new DbContextOptionsBuilder<MyProjectNameMigrationsDbContext>()
        .UseSqlite(connection)
        .Options;
    using (var context = new MyProjectNameMigrationsDbContext(options))
    {
        context.GetService<IRelationalDatabaseCreator>().CreateTables();
    }
    return connection;
}

I have a similar problem where I need to handle DateTimeOffset data and sqlite. I found this article. Where would I typically add the code? How do I create a separate DbContext for the unit tests? Today the tests use the MigrationsDbContext. I could edit the proper EntityFrameworkCore.DbContext and add code to the OnModelCreating and check if the the database is sqlite but that seems like the wrong way.

You can create a DbContext in the unit test to change DecimalProperty.

The Decimal type provides a high level of precision. If you don't need that level of precision, however, we recommend using double instead. You can use a value converter to continue using decimal in your classes.

modelBuilder.Entity<MyEntity>() 
.Property(e => e.DecimalProperty) 
.HasConversion<double>();****

Thank you! I've added the attribute [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] and now the response is 401 Unauthorized. May I ask if this attribute could have any other unwanted consequences?

Showing 1 to 10 of 16 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06