Dbcontext verlor nach dem upgrade ef core von 5 auf 9C#

Ein Treffpunkt für C#-Programmierer
Anonymous
 Dbcontext verlor nach dem upgrade ef core von 5 auf 9

Post by Anonymous »

Wir verwenden EF Core 5 seit einiger Zeit in mehreren Anwendungen, hatten aber nie die Zeit, es zu aktualisieren, auch wegen Abhängigkeiten. Habe es aktualisiert, es gab fast keine Aktualisierungen des Code, der benötigt wird. Vor Ort in Visual Studio gibt es kein Problem. Aber sobald wir eingesetzt waren, stießen wir auf ein Problem. Zuerst gibt es kein Problem, die Website ist in Betrieb, wir können auf die Datenbank zugreifen. /p>

System.invalidoperationException: Für diesen DBContext wurde kein Datenbankanbieter konfiguriert. Ein Anbieter kann konfiguriert werden, indem die Methode "dbContext.onconconfiguring" überschreibt oder "adddbContext" im Anwendungsdienstanbieter verwendet wird. Wenn 'adddbContext' verwendet wird, stellen Sie außerdem sicher, dass Ihr DBContext -Typ ein DBContextOptions -Objekt in seinem Konstruktor akzeptiert und an den Basiskonstruktor für dbContext übergibt. .Initialize (IserviceProvider ScopedProvider, dbContextOptions ContextOptions, DbContext Context)

unter microsoft.entityFrameworkcore.dbcontext.get_contextservices ()

unter microsoft.entityFrameworkCore.dbcontext.get_model ()

AT AT AT ATINE Microsoft.EntityFrameworkCore.Internal.Internaldbset

Code: Select all

1.get_EntityType()   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet< /code> 1.Checkstate ()

unter microsoft.entityFrameworkcore.internal.Internaldbset1.get_EntityQueryable()   at Microsoft.EntityFrameworkCore.Internal.InternalDbSet< /code> 1.System.collectionss.generic.IAsyncenumerable.getAsyncenumerator (CancellationToken CancellationToken)

at system.runtime.comPilerservices.ConfiguredCancelableAsyNcenumerable1.GetAsyncEnumerator()   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable< /code> 1 Quelle, CancellationToken CancellationToken)

at beheer.services.dashboard.dashboardService.getMaxdaysfromSettings () in d: \ Agenten \ Agent.morpheus_work \ 2 \ S \ Back-End \ Beher. Services \ Dashboard \ DashboardService.cs: Zeile 330

at beheer.services.dashboard.dashboardService.getRecenterrorlogs (Paging Paging) in D: \ Agents \ Agent.morpheus_work \ 2 \ S \ Back-End \ BEHEER.Services \ Dashboard \ DashBoardservice.Cs: Linie 137

at Eheer.api.controllers.dashboardcontroller.getRecenterrorlogs (Paging Paging) in D: \ Agents \ Agent.morpheus_work \ 2 \ S \ Back-End \ BEHEER.API \ Controllers \ DashboardController.cs: Zeile 99
bei lambda_method62 (Verschluss, Objekt)

at microsoft.aspnetcore.mvc.infrastructure.actionMethodexecutor.AwaitableObjectresultexecutor.execute (ActionContext ActionContext, iactionResultTyper -Mapper, ObjectMethodexecutor, Objektverträge, Objekt, Objekt, Objekt [] argument []

AT - Microsoft.aspnetcore.mvc.infrastructure.controlleractionInvoker.g__Awaited | 12_0 (ControllerActionInvoker Invoker, Valuetask`1 ActionResultvalUetask)

at microsoft.aspnetcore.Mvc.infRastructure.ControllerVoker. Invoker, Task LastTask, Status Nächst = "Lang-CS PrettyPrint-Override">public static class Program
{
public static void Main(string[] args)
{
CreateHostBuilder(args).Build().Run();
}

private static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment.EnvironmentName;
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
config.AddJsonFile($"appsettings.{env}.json", optional: true, reloadOnChange: true);
config.AddEnvironmentVariables();

if (args != null)
{
config.AddCommandLine(args);
}
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup();
})
.UseSerilog((hostingContext, loggerConfiguration) => loggerConfiguration
.ReadFrom.AppSettings().Enrich.FromLogContext());
}
< /code>
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}

public IConfiguration Configuration { get; }

// This method gets called by the runtime.  Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
var connectionString = Configuration["AppSettings:ConnectionString"];
services.AddDbContext(options => options.UseOracle(connectionString));

// ....
}
}
< /code>
public class MyContext : DbContext
{
public MyContext()
{
}

public MyContext(DbContextOptions options)
: base(options)
{
}

public virtual DbSet SenderSettings { get; set; }

protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
}
}
Eine Anleitung, was als nächstes zu tun ist.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post