Точка входа не была найдена, когда.Dotnet Core 2.0 EfCore - PullRequest
0 голосов
/ 03 апреля 2019

Пытаясь убедиться, что моя база данных была создана, я делаю следующее в классе statup:

 using (var scope = app.ApplicationServices.GetService<IServiceScopeFactory>().CreateScope())
 {
     var context = scope.ServiceProvider.GetRequiredService<MyContext>();
     context.Database.EnsureCreated();
 }

Я зарегистрировал контекст в ServiceCollection следующим образом:

 services.AddDbContext<MyDbContext>(options => options.UseSqlServer(connectionString));

При вызове EnsureCreated() я получаю следующее исключение:

DependencyResolutionException: An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[mynamespace.Data.MyDbContext])' on type 'MyDbContext'. ---> Entry point was not found. (See inner exception for details.)

DependencyResolutionException: An error occurred during the activation of a particular registration. See the inner exception for details. Registration: Activator = ChtrDbContext (ReflectionActivator), Services = [chtr.server.data.Data.ChtrDbContext], Lifetime = Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = Shared, Ownership = OwnedByLifetimeScope ---> An exception was thrown while invoking the constructor 'Void .ctor(Microsoft.EntityFrameworkCore.DbContextOptions`1[mynamespace.MyDbContext])' on type 'MyDbContext'. ---> Entry point was not found. (See inner exception for details.) (See inner exception for details.)

Стоит отметить, что я использую Autofac в качестве своей IoC Framework

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...