'Why is my old DbContext being called instead of my new DbContext?
I am trying to get refreshed data but everytime I make my calls, it seems that the data being called is from the old dbcontext and not the new one.
Here is my code:
private async Task FetchData()
{
binaryData = await binaryService.GetDataAsync();
await InvokeAsync(StateHasChanged);
}
My binary service is working well as when my application loads it makes a call to the binary service on initialized and the data displayed is correct.
protected override async Task OnInitializedAsync()
{
binaryData = await binaryService.GetDataAsync();
}
I dont understand why my service call is pointing towards my old dbcontext and not the new instance.
services.AddTransient<BinaryService>();
services.AddDbContext<BinaryContext>(options => {
options.UseLazyLoadingProxies()
.UseSqlServer(Configuration.GetConnectionString("BinaryContext"));
}, ServiceLifetime.Transient);
I cant see where Im going wrong, ive tried changing everything to transient but where it makes sense but that doesnt seem to work. Any help is welcome thanks!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
