There is another issue in the generated EfCoreEntityRepository.cs class
The issue corresponds to the **FindAsync **method inside the **EfCoreRepository ** class
There seems to be a problem between the nullable-enabled project and the non-enabled nullable project (EntityFramework Project).
One method returns a nullable type while the other expects a non-nullable return value.This is a critical error for the new version.
3>EfCoreUbigeoRepository.cs(14,106): Error CS8613 : Nullability of reference types of the return type of "Task<Ubigeo> EfCoreRepository<DemoDbContext, Ubigeo>.FindAsync(Expression<Func<Ubigeo, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" does not match member "Task<Ubigeo?> IRepository<Ubigeo>.FindAsync(Expression<Func<Ubigeo, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" implemented implicitly. 3>EfCoreUbigeoRepository.cs(14,106): Error CS8613 : Nullability of reference types of the return type of "Task<Ubigeo> EfCoreRepository<DemoDbContext, Ubigeo, Guid>.FindAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" does not match the implicitly implemented member "Task<Ubigeo?> IReadOnlyBasicRepository<Ubigeo, Guid>.FindAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))". 3>------- Finished building project: D.EntitemoyFrameworkCore. Succeeded: False. Errors: 2. Warnings: 0
The solution for this is the following.
In **EfCoreRepository.cs **
Replace this code:
public async override Task<TEntity> FindAsync( Expression<Func<TEntity, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default) { return includeDetails ? await (await WithDetailsAsync()) .Where(predicate) .SingleOrDefaultAsync(GetCancellationToken(cancellationToken)) : await (await GetDbSetAsync()) .Where(predicate) .SingleOrDefaultAsync(GetCancellationToken(cancellationToken)); }
For this
public async override Task<TEntity?> FindAsync( Expression<Func<TEntity, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default) { return includeDetails ? await (await WithDetailsAsync()) .Where(predicate) .SingleOrDefaultAsync(GetCancellationToken(cancellationToken)) : await (await GetDbSetAsync()) .Where(predicate) .SingleOrDefaultAsync(GetCancellationToken(cancellationToken)); }
And replace this code:
public virtual async Task<TEntity> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default) { return includeDetails ? await (await WithDetailsAsync()).OrderBy(e => e.Id).FirstOrDefaultAsync(e => e.Id.Equals(id), GetCancellationToken(cancellationToken)) : await (await GetDbSetAsync()).FindAsync(new object[] { id }, GetCancellationToken(cancellationToken)); }
For this one
public virtual async Task<TEntity?> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return includeDetails
? await (await WithDetailsAsync()).OrderBy(e => e.Id).FirstOrDefaultAsync(e => e.Id.Equals(id), GetCancellationToken(cancellationToken))
: await (await GetDbSetAsync()).FindAsync(new object[] { id }, GetCancellationToken(cancellationToken));
}Hi,
Is there any news about this issue?
Thanks!
Hi Rafael, thanks for reporting. We have already fixed this (see https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs#L304) and enabled nullable annotations for all projects of both ABP Framework & ABP Commercial (https://github.com/abpframework/abp/issues/16610) and it will be available in v8.0.
Thanks for your answer!!
Why is not that solution included in 7.4? In my opinion, the fix of EfCoreRepository, it's critical because it can lead to data issues right now. Is it possible to include at least the EfCoreRepository fix only or a temporary workaround?
There is another issue in the generated EfCoreEntityRepository.cs class
The issue corresponds to the **FindAsync **method inside the **EfCoreRepository ** class
There seems to be a problem between the nullable-enabled project and the non-enabled nullable project (EntityFramework Project).
One method returns a nullable type while the other expects a non-nullable return value.This is a critical error for the new version.
3>EfCoreUbigeoRepository.cs(14,106): Error CS8613 : Nullability of reference types of the return type of "Task<Ubigeo> EfCoreRepository<DemoDbContext, Ubigeo>.FindAsync(Expression<Func<Ubigeo, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" does not match member "Task<Ubigeo?> IRepository<Ubigeo>.FindAsync(Expression<Func<Ubigeo, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" implemented implicitly. 3>EfCoreUbigeoRepository.cs(14,106): Error CS8613 : Nullability of reference types of the return type of "Task<Ubigeo> EfCoreRepository<DemoDbContext, Ubigeo, Guid>.FindAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" does not match the implicitly implemented member "Task<Ubigeo?> IReadOnlyBasicRepository<Ubigeo, Guid>.FindAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))". 3>------- Finished building project: D.EntitemoyFrameworkCore. Succeeded: False. Errors: 2. Warnings: 0
The solution for this is the following.
In **EfCoreRepository.cs **
Replace this code:
public async override Task<TEntity> FindAsync( Expression<Func<TEntity, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default) { return includeDetails ? await (await WithDetailsAsync()) .Where(predicate) .SingleOrDefaultAsync(GetCancellationToken(cancellationToken)) : await (await GetDbSetAsync()) .Where(predicate) .SingleOrDefaultAsync(GetCancellationToken(cancellationToken)); }
For this
public async override Task<TEntity?> FindAsync( Expression<Func<TEntity, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default) { return includeDetails ? await (await WithDetailsAsync()) .Where(predicate) .SingleOrDefaultAsync(GetCancellationToken(cancellationToken)) : await (await GetDbSetAsync()) .Where(predicate) .SingleOrDefaultAsync(GetCancellationToken(cancellationToken)); }
And replace this code:
public virtual async Task<TEntity> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default) { return includeDetails ? await (await WithDetailsAsync()).OrderBy(e => e.Id).FirstOrDefaultAsync(e => e.Id.Equals(id), GetCancellationToken(cancellationToken)) : await (await GetDbSetAsync()).FindAsync(new object[] { id }, GetCancellationToken(cancellationToken)); }
For this one public virtual async Task<TEntity?> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default) { return includeDetails ? await (await WithDetailsAsync()).OrderBy(e => e.Id).FirstOrDefaultAsync(e => e.Id.Equals(id), GetCancellationToken(cancellationToken)) : await (await GetDbSetAsync()).FindAsync(new object[] { id }, GetCancellationToken(cancellationToken)); }
Hi,
Is there any news about this issue?
Thanks!
Another observation,
There is no lepton 2.4.0-rc.3, is this normal?
There is another issue in the generated EfCoreEntityRepository.cs class
The issue corresponds to the **FindAsync **method inside the **EfCoreRepository ** class
There seems to be a problem between the nullable-enabled project and the non-enabled nullable project (EntityFramework Project). One method returns a nullable type while the other expects a non-nullable return value.
This is a critical error for the new version.
3>EfCoreUbigeoRepository.cs(14,106): Error CS8613 : Nullability of reference types of the return type of "Task<Ubigeo> EfCoreRepository<DemoDbContext, Ubigeo>.FindAsync(Expression<Func<Ubigeo, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" does not match member "Task<Ubigeo?> IRepository<Ubigeo>.FindAsync(Expression<Func<Ubigeo, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" implemented implicitly. 3>EfCoreUbigeoRepository.cs(14,106): Error CS8613 : Nullability of reference types of the return type of "Task<Ubigeo> EfCoreRepository<DemoDbContext, Ubigeo, Guid>.FindAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" does not match the implicitly implemented member "Task<Ubigeo?> IReadOnlyBasicRepository<Ubigeo, Guid>.FindAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))". 3>------- Finished building project: D.EntitemoyFrameworkCore. Succeeded: False. Errors: 2. Warnings: 0
The solution for this is the following.
In **EfCoreRepository.cs **
Replace this code:
public async override Task<TEntity> FindAsync(
Expression<Func<TEntity, bool>> predicate,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return includeDetails
? await (await WithDetailsAsync())
.Where(predicate)
.SingleOrDefaultAsync(GetCancellationToken(cancellationToken))
: await (await GetDbSetAsync())
.Where(predicate)
.SingleOrDefaultAsync(GetCancellationToken(cancellationToken));
}
For this
public async override Task<TEntity?> FindAsync(
Expression<Func<TEntity, bool>> predicate,
bool includeDetails = true,
CancellationToken cancellationToken = default)
{
return includeDetails
? await (await WithDetailsAsync())
.Where(predicate)
.SingleOrDefaultAsync(GetCancellationToken(cancellationToken))
: await (await GetDbSetAsync())
.Where(predicate)
.SingleOrDefaultAsync(GetCancellationToken(cancellationToken));
}
And replace this code:
public virtual async Task<TEntity> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default)
{
return includeDetails
? await (await WithDetailsAsync()).OrderBy(e => e.Id).FirstOrDefaultAsync(e => e.Id.Equals(id), GetCancellationToken(cancellationToken))
: await (await GetDbSetAsync()).FindAsync(new object[] { id }, GetCancellationToken(cancellationToken));
}
For this one public virtual async Task<TEntity?> FindAsync(TKey id, bool includeDetails = true, CancellationToken cancellationToken = default) { return includeDetails ? await (await WithDetailsAsync()).OrderBy(e => e.Id).FirstOrDefaultAsync(e => e.Id.Equals(id), GetCancellationToken(cancellationToken)) : await (await GetDbSetAsync()).FindAsync(new object[] { id }, GetCancellationToken(cancellationToken)); }
There is another issue in the generated EfCoreEntityRepository.cs class
The issue corresponds to the **FindAsync **method inside the **EfCoreRepository ** class
There seems to be a problem between the nullable-enabled project and the non-enabled nullable project (EntityFramework Project). One method returns a nullable type while the other expects a non-nullable return value.
This is a critical error for the new version.
3>EfCoreUbigeoRepository.cs(14,106): Error CS8613 : Nullability of reference types of the return type of "Task<Ubigeo> EfCoreRepository<DemoDbContext, Ubigeo>.FindAsync(Expression<Func<Ubigeo, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" does not match member "Task<Ubigeo?> IRepository<Ubigeo>.FindAsync(Expression<Func<Ubigeo, bool>> predicate, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" implemented implicitly.
3>EfCoreUbigeoRepository.cs(14,106): Error CS8613 : Nullability of reference types of the return type of "Task<Ubigeo> EfCoreRepository<DemoDbContext, Ubigeo, Guid>.FindAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))" does not match the implicitly implemented member "Task<Ubigeo?> IReadOnlyBasicRepository<Ubigeo, Guid>.FindAsync(Guid id, bool includeDetails = true, CancellationToken cancellationToken = default(CancellationToken))".
3>------- Finished building project: D.EntitemoyFrameworkCore. Succeeded: False. Errors: 2. Warnings: 0
ABP Suite still generates EntityManager generated class with methods without null validation checking
In this example the GeoManager class is generating a Create Method with a parameter of type "string codigoInei = null".
It should be "string? codigoInei = null". This complicates us if I want to re-generate the ABP Suite. I will need to fix everytime.