Product Version: V13.20
Product Type: Angular
Product Framework: .Net Core6
Hi,
We have migrated code from 9.2.0 to 13.2.0, the application is running, we can create tenant, and login as a tenant. When we try to create user under host or tenant, we get an internal error with **GetDbContext() **is null. Could you kindly guide to resolve the issue please.
Many Thanks
14 Answer(s)
-
0
Hi Support Team,
Additional Information:
Upon further investigation, I found that the DbContext.cs file in the new codebase version (13.2.0) contains 134 lines of code. However, during migration, we pulled our old code with the DbContext.cs file from our old codebase, which has around 1400 lines of code, including all the entities.Could this discrepancy in the DbContext.cs file be causing the GetDbContext() null issue mentioned earlier? If yes, could you advise on the best approach to resolve this? Should we retain the old code, or is it necessary to adapt to the new version's structure?
Many Thanks.
-
0
Hi @Jorahealth
In order to provide better assistance for this situation, can you share your project with us at support@aspnetzero.com?
-
0
Hi,
I have sent an email to support@aspnetzero.com with the project files attached, as requested. Please let me know if you require any additional details or further clarification.
Looking forward to your response.
Many Thanks.
-
0
Hi @Jorahealth
The issue here is that the DbContext instance is automatically managed during the UnitOfWork process. If a UnitOfWork process has not started, the GetDbContext() call will return null. You can directly access the active DbContext using the IUnitOfWorkManager.
public class AdoRepository : DecisivelyRepositoryBase, IAdoRepository { private readonly IActiveTransactionProvider _transactionProvider; private readonly DecisivelyDbContext _dbContext; public AdoRepository( IDbContextProvider dbContextProvider, IActiveTransactionProvider transactionProvider, IUnitOfWorkManager unitOfWorkManager) : base(dbContextProvider) { _transactionProvider = transactionProvider; _dbContext = unitOfWorkManager.Current?.GetDbContext(); } // ... }
-
0
Dear Support Team,
Thank you for your detailed response and suggestion regarding the UnitOfWork process. The issue has been resolved successfully based on your guidance, and everything is now working as expected.
I have one follow-up question:
Is this solution a custom fix or workaround specific to our scenario?
If not, could you clarify why this approach or guidance is not included in the base version by default?
Your insight would be greatly appreciated.Many Thanks.
-
0
Hi @Jorahealth
We have made a suggestion like this because you want to inject
dbContext
with DI. Here you can also perform your operations by using theGetDbContext
method coming from YourProjectNameRepositoryBase.[UnitOfWork] public class AdoRepository : DecisivelyRepositoryBase, IAdoRepository { private readonly IActiveTransactionProvider _transactionProvider; public AdoRepository(IDbContextProvider dbContextProvider, IActiveTransactionProvider transactionProvider) : base(dbContextProvider) { _transactionProvider = transactionProvider; } private SqlCommand CreateCommand(string commandText, CommandType commandType, params SqlParameter[] parameters) { var command = GetDbContext().Database.GetDbConnection().CreateCommand(); //... } private async Task EnsureConnectionOpenAsync() { var connection = GetDbContext().Database.GetDbConnection(); //... } }
-
0
Hi Support Team,
Thank you so much for your response.
We recently migrated our codebase from version 9.2.0 to 13.2.1, and we are now attempting to configure our old database with the new migrated code. However, we are encountering issues when running the migrator.
The primary challenge seems to be related to differences in the database schema:
The new version introduces additional columns, such as " RecoveryCode ", which are not present in the old database schema.
This discrepancy appears to be causing errors during the migration process.
Could you kindly advise on the best approach to use our old database with the new migrated code? Should we manually update the old database schema to align with the new codebase, or is there a recommended process for handling this situation?Looking forward to your guidance.
Many thanks.
-
0
Hi @Jorahealth,
You can incorporate new changes into your project by adding a migration. If you prefer, you can also delete all existing migrations and create a new one to manage this process.
https://www.learnentityframeworkcore.com/migrations/add-migration -
0
Dear Support Team,
First of all, I would like to thank you for your prompt and helpful responses to my previous queries. Your guidance has been invaluable, and I truly appreciate the support you’ve provided so far.
I’m reaching out again regarding another issue with the permissions functionality in our application.
Issue Details:
In the new Angular base code (v18), the functionality for adding permissions to users is working perfectly.
However, in the migrated Angular code (v10 to v18), the same functionality does not work.
I have not modified any of the related components or shared files during the migration and copied all relevant files from the new base code.
I also compared the connected components in both versions, and there are no visible code differences.Could you kindly suggest what might be causing this discrepancy? Are there any hidden dependencies or configurations that might affect this functionality in the migrated code?
I greatly value your assistance and look forward to your guidance in resolving this issue.
Many thanks.
-
0
Hi @Jorahealth
Can you elaborate on a few points so we can better understand your issue? Are you having trouble with the permission tree, which lists permissions on the user interface and makes them selectable? Apart from that, can you share your
primeng
package version with us? -
0
Hi,
Thank you for your response.
To address your queries:
Clarification of the Issue:
Yes, the issue is with the permission tree on the user interface.
The tree lists the permissions and displays them correctly, but I am unable to select or add permissions in the Angular migrated code(Angular side Permissions functionality issue). This functionality works as expected in the new Angular base code.PrimeNG Package Version:
The PrimeNG package version in my migrated code is "primeng": "^17.18.5".
Please let me know if there’s any additional information or context you need to help diagnose the issue.
Looking forward to your guidance.
Many thanks. -
0
Hi @Jorahealth
We created an issue for this. This problem will not occur when we upgrade the primeng package. Can you try the situation mentioned in this issue comment?
-
0
Hi,
I attempted to access the link you suggested, but unfortunately, it is redirecting to a 404 error message. To address the issue I’ve been experiencing with the permissions tree:I upgraded my PrimeNG version from 17.18.5 to 18.0.2 and also updated the primeicons to the latest version.
I searched for related tickets or documentation about similar PrimeNG issues but couldn’t find any relevant solutions.
Despite these efforts, the issue persists. Could you kindly suggest further troubleshooting steps or direct me to the appropriate resources? -
0
Hi
After logging in with the user who has the plan on the aspnetzero.com website, clicking the manage button under the Account button, you can give permission to the github user you are trying to log in from the Github Members tab on the relevant page.