Custom Database Tables with Entity Framework
# help-with-umbraco
n
I have this setup in saving data to database
Copy code
public async Task SaveReferralOrganisation(ReferralOrganisation referralOrganisation)
        {
            using IEfCoreScope<ReferralOrganisationContext> scope = _referralOrganisationContextEfCoreScopeProvider.CreateScope();

            await scope.ExecuteWithContextAsync<Task>(async db =>
            {
                db.ReferralOrganisation.Add(referralOrganisation);
                await db.SaveChangesAsync();
            });

            scope.Complete();
        }
but Im getting this error > System.InvalidOperationException: 'The Scope 8640247c-4ebb-4e8b-8121-ebb935376e0b being disposed is not the Ambient Scope 062154f1-4f4f-4f59-bdf6-0c768a4951eb. This typically indicates that a child Scope was not disposed, or flowed to a child thread that was not awaited, or concurrent threads are accessing the same Scope (Ambient context) which is not supported. If using Task.Run (or similar) as a fire and forget tasks or to run threads in parallel you must suppress execution context flow with ExecutionContext.SuppressFlow() and ExecutionContext.RestoreFlow().' > Anyone have already experienced this before ?
59 Views