aspnetboilerplate: QUESTION: All unit tests failing after upgrading from ABP v9.0 to v.10
Hello 😃 I’ve been using ABP since the first versions but I’m stuck with this simple upgrade…
After upgrading from ABP v9.0 to v.10 all my unit tests are failing with the following exception:
Abp.AbpException: There is no tenant with given id: 1
MultiTenancy is disabled. In the project TestBase constructor, I have something similar to this:
UsingDbContext(context =>
{
new InitialHostDbBuilder(context).Create();
new DefaultTenantBuilder(context).Create();
});
I noticed that the tenant with ID = 1 is in the context:
UsingDbContext(context =>
{
var tenant = context.Tenants.Find(1); // => OK
});
However, it fails to find the tenant if I use a repository using DI:
var tenantRepository = LocalIocManager.Resolve<IRepository<Tenant>>(); // Just to illustrate the issue.
var tenant = tenantRepository.FirstOrDefault(1); => KO - Returns null
EF Core memory is setup like this:
...
var builder = new DbContextOptionsBuilder<MyDbContext>();
builder.UseLazyLoadingProxies().UseInMemoryDatabase(Guid.NewGuid().ToString());
iocManager.IocContainer.Register(
Component
.For<DbContextOptions<MyDbContext>>()
.Instance(builder.Options)
.LifestyleSingleton()
);
builder.UseInternalServiceProvider(serviceProvider);
Do you have any ideas, by any chance?
Thanks for the support.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 36 (13 by maintainers)
@thibnes could you try using this extension method ?
I will check if we can support
UseLazyLoadingProxiesagain.Here is the repro sample @ismcagdas in the branch abo/test_event_handler of https://github.com/thibnes/Abp-UnitTestsIssue.git
Hi, I’ll try to create a reproduction sample soon.
I confirm, everything works now! Thank you so much!!
I got the invitation and accept it.
Hi @ismcagdas, I managed to create a reproduction project and sent you an invite to access the repository.