question

PrakashM-8873 avatar image
0 Votes"
PrakashM-8873 asked PrakashM-8873 answered

not able to retrieve only entites from (IDbSet<TEntity> _entities) without converting into list throwing error "the function requires all threads to run"

not able to retrieve only entites from (IDbSet<TEntity> _entities) without converting into list throwing error "the function requires all threads to run".

dotnet-entity-frameworkdotnet-sqlite
· 6
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Please someone help me to resolve this problem, because at some places its working as expected.
But sometimes throwing error.

0 Votes 0 ·

Show some codel where this is happening.

0 Votes 0 ·

internal sealed class GenericRepository<TEntity> : IGenericRepository<TEntity> where TEntity : class
{
#region Global Variables
private readonly BVTEntities context;
private readonly IDbSet<TEntity> _entities;

     /// <summary>
     /// Base entity
     /// </summary>
     IDbSet<TEntity> IGenericRepository<TEntity>.Table => this._entities;
     #endregion
     .........

}

when I am trying to access this property from my code, its throwing error

Calling code:

99571-image.png


0 Votes 0 ·
image.png (16.3 KiB)

This similar code was working fine till a month back, but now suddenly one by one the methods present in Generic repository got started to malfunction.

0 Votes 0 ·

These methods also present in Generic Repository, but only the highlighted method works.

public TEntity GetById(Guid id)
{
return _entities.Find(id);
}


/// <summary>
/// Get all records.
/// </summary>
/// <returns></returns>
public IEnumerable<TEntity> GetAll()
{
return _entities.ToList();
}

4 days back, I updated my entity framework version from 6.4.0 to 6.4.4 ( is this causing any issue)
@DuaneArnold-0443

0 Votes 0 ·

EF is already using the Repository pattern, and the usage of the generic Repository over EF is not optimal. I avoid using the generic repository. I don't know you changing to framework 6.4.0 is causing problems. Does EF have a 6.4.4 version?

https://docs.microsoft.com/en-us/dotnet/api/system.data.entity.dbcontext?view=entity-framework-6.2.0




0 Votes 0 ·
AddWebSolution-0525 avatar image
0 Votes"
AddWebSolution-0525 answered

Try using this :-
db.Configuration.ProxyCreationEnable = false;

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

PrakashM-8873 avatar image
0 Votes"
PrakashM-8873 answered

Thank you so much for all your valuable inputs. @DuaneArnold-0443 @AddWebSolution-0525

The root cause of the issue was due to this below-mentioned line was missing from the windows service startup file,

Environment.SetEnvironmentVariable("AppendManifestToken_SQLiteProviderManifest", ";BinaryGUID=True;");

Mistakenly it got removed and created big chaos in the application.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.