What replaced Services.CreateScope() in 2.1?
I am trying to follow this tutorial but it seems like stuff has changed quite a bit
https://dotnetthoughts.net/seed-database-in-aspnet-core/
CreateScope also is used for any root application containers like webhost service provider.Root application providers and all objects it create will live for the life of the application.If we resolve scoped or transient services from root container instance they will be created as singletons.Instead by using scope we ...
To use Entity Framework 6, your project has to compile against . NET Framework, as Entity Framework 6 doesn't support . NET Core. If you need cross-platform features you will need to upgrade to Entity Framework Core.
An instance of IServiceProvider itself can be obtained by calling a BuildServiceProvider method of an IServiceCollection . IServiceCollection is a parameter of ConfigureServices method in a Startup class. It seems to be magically called with an instance of IServiceCollection by the framework.
I had the same problem with the ASP.NET Core MVC with Entity Framework Core tutorial, written for .NET Core 2, trying to run it with .NET Core 2.1. It worked fine once I added
using Microsoft.Extensions.DependencyInjection;
to the problem file, in my case Program.cs.
You should replace this line of code:
var host = BuildWebHost(args);
with this
var host = CreateWebHostBuilder(args).Build();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With