Value cannot be null. Parameter Name: connectionstring - when trying to switch to MSSQL from SQLITE - asp.net

I get this beauty when I am trying to switch to MSSQL database which I installed on my local machine.
System.ArgumentNullException: Value cannot be null.
Parameter name: connectionString
at Microsoft.EntityFrameworkCore.Utilities.Check.NotEmpty(String value, String parameterName)
at Microsoft.EntityFrameworkCore.SqlServerDbContextOptionsExtensions.UseSqlServer(DbContextOptionsBuilder optionsBuil
der, String connectionString, Action`1 sqlServerOptionsAction)
at MSBlog.Startup.<ConfigureServices>b__4_0(DbContextOptionsBuilder options)
at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TConte
xt](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCa
llSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvide
r provider)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider prov
ider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider p
rovider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCa
llSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitClosedIEnumerable(ClosedIEnume
rableCallSite closedIEnumerableCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite tr
ansientCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvide
r provider)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider prov
ider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider p
rovider)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.FindContextTypes()
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.GetContextTypes()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.GetContextTypesImpl()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass4_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Value cannot be null.
Parameter name: connectionString
"ConnectionStrings": {
"DefaultConenction" : "Server=localhost;Database=db;User Id=user;Password=pw;Trusted_Connection=True;",
"OldConnection": "DataSource=.\\some.db"
},
I also changed the AddDbContext call in Startup.cs to:
services.AddDbContext<ApplicationDbContext>( options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
And lastly I just added my new models to the ApplicationDbContext as DbSets.
What am I doing wrong?
Any command I run that starts with dotnet ef results in the error above and I can't figure out what is null.
These are the versions I am running:
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.2" PrivateAssets="All" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.0.0-msbuild3-final" PrivateAssets="All" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.2" />
Please help!

Correct the spelling of DefaultConenction in your configuration.

Related

ASP.NET Core 6 MVC and Entity Framework Core 7.0 - can't connect to Sqlite

I just upgraded from EF 6 -> EF Core 7 in my ASP.NET Core 6 MVC app because I needed the context.Database.SqlQuery<T>() functionality; however, when I try to run any query via EF it now appears unable to connect at all when I build & run or execute migration cmds:
C:\Path\To\My\Project\Ui>dotnet ef database update --context sqliteascertodbcontext
Build started...
Build succeeded.
Debug: Registered integration with EF Core.
An error occurred using the connection to database 'main' on server 'C:\Path\To\My\Project\Ui\db.sqlite3'.
Microsoft.Data.Sqlite.SqliteException (0x80004005): SQLite Error 1: ''.
at Microsoft.Data.Sqlite.SqliteConnection.LoadExtensionCore(String file, String proc)
at Microsoft.Data.Sqlite.SqliteConnection.Open()
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenDbConnection(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternal(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Open(Boolean errorsExpected)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteScalar(RelationalCommandParameterObject parameterObject)
at Microsoft.EntityFrameworkCore.Migrations.HistoryRepository.Exists()
at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String targetMigration, String connectionString, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
SQLite Error 1: ''.
CSProject contents:
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.SpaServices.Extensions" Version="6.0.11" />
<PackageReference Include="Microsoft.Data.Sqlite.Core" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.0" />
<PackageReference Include="Microsoft.Owin" Version="4.2.0" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.17.0" />
<PackageReference Include="Microsoft.Owin.Security" Version="4.2.0" />
<PackageReference Include="Microsoft.Owin.Security.OAuth" Version="4.2.0" />
<PackageReference Include="Microsoft.Owin.Security.Jwt" Version="4.2.0" />
<PackageReference Include="Microsoft.Identity.Web" Version="1.23.1" />
<PackageReference Include="Sentry.AspNetCore" Version="3.22.0" />
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.6.2" />
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="2.1.3" />
<PackageReference Include="VueCliMiddleware" Version="3.1.2" />
</ItemGroup>
Is there anything missing, or?

Could not load file or assembly 'Microsoft.SqlServer.Server'

I am trying to make a simple insert into my sqlserver database using Dapper. This is my code:
using var db = DbContext.CreateConnection();
db.Open();
string sqlQuery =
"INSERT INTO Account (Id, Balance, NumberOfTransactions) VALUES(#Id, #Balance, #NumberOfTransactions)";
int rowsAffected = db.Execute(sqlQuery, entity);
return rowsAffected > 0;
And this is my DapperContext.
public DapperContext(IConfiguration configuration)
{
_configuration = configuration;
_connectionString = _configuration.GetConnectionString("DapperConnection");
}
public IDbConnection CreateConnection()
=> new SqlConnection(_connectionString);
But when I reach the Execute line I am getting Could not load file or assembly 'Microsoft.SqlServer.Server'. I have no idea why. My SQLServer is being hosted by a docker image. And I've already installed the Server nuget. Here's the list of nugets that I currently have installed:
<PackageReference Include="Akka" Version="1.4.39" />
<PackageReference Include="Akka.DependencyInjection" Version="1.4.39" />
<PackageReference Include="Akka.Remote" Version="1.4.39" />
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Dapper.EntityFramework" Version="2.0.90" />
<PackageReference Include="Microsoft.Data.SqlClient" Version="5.0.0-preview3.22168.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-preview.5.22302.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0-preview.5.22302.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0-preview.5.22302.2" />
<PackageReference Include="Microsoft.SqlServer.Server" Version="1.0.0" />
<PackageReference Include="Microsoft.SqlServer.Types" Version="160.600.9-ctp2p0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
Anyone can help me what might be wrong here and why do I keep getting this could not load error? I even already download SQL Server from Microsoft but my idea was to use my docker container instead.
Stack trace:
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.SqlServer.Server, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'. The system cannot find the file specified.
File name: 'Microsoft.SqlServer.Server, Version=5.0.0.0, Culture=neutral, PublicKeyToken=23ec7fc2d6eaa4a5'
I was using the wrong version of the nuget package. I had to replace PackageReference Include="Microsoft.Data.SqlClient" Version="5.0.0-preview3.22168.1 with PackageReference Include="System.Data.SqlClient" Version="4.8.3" and it worked right away

migration .Net Framework 4.8 to .Net Core 6 - Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0

I just migrated My project from the .net framework 4.8 to the .Net core 6
My Projects have a lot of dependencies like Owin, IdentityServer3, and ...
Finally, my solution builds successfully now, but when I start that I ran to this error :
Could not load file or assembly 'System.IdentityModel, Version=4.0.0.0...
Assuming that I can't migrate the identityServer3 and as a result, I can't update any of the Owin packages, (the Owin(s) version should be less than 4), is there a chance to embed the System.IdentityModel into the .Net 6 web projects?
the csproj file :
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BrockAllen.MembershipReboot" Version="9.0.0" />
<PackageReference Include="BrockAllen.MembershipReboot.Ef" Version="9.0.0" />
<PackageReference Include="EasyNetQ" Version="6.3.1" />
<PackageReference Include="EasyNetQ.DI.Ninject" Version="6.3.1" />
<PackageReference Include="EntityFramework" Version="6.4.4" />
<PackageReference Include="FluentValidation" Version="10.3.6" />
<PackageReference Include="IdentityModel" Version="1.9.2" />
<PackageReference Include="IdentityServer3" Version="2.6.3" />
<PackageReference Include="IdentityServer3.AccessTokenValidation" Version="2.14.0" />
<PackageReference Include="loggly-csharp" Version="4.6.1.76" />
<PackageReference Include="loggly-csharp-config" Version="4.6.1.76" />
<PackageReference Include="Microsoft.AspNet.Cors" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNet.SignalR.Core" Version="2.4.2" />
<PackageReference Include="Microsoft.AspNet.SignalR.SystemWeb" Version="2.4.2" />
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Owin" Version="6.0.1" />
<PackageReference Include="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" Version="3.6.0" />
<PackageReference Include="Microsoft.IdentityModel.Protocol.Extensions" Version="1.0.2.206221351" />
<PackageReference Include="Microsoft.Net.Compilers" Version="4.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Owin" Version="3.1.0" />
<PackageReference Include="Microsoft.Owin.Cors" Version="3.1.0" />
<PackageReference Include="Microsoft.Owin.Host.HttpListener" Version="3.1.0" />
<PackageReference Include="Microsoft.Owin.Host.SystemWeb" Version="3.1.0" />
<PackageReference Include="Microsoft.Owin.Hosting" Version="3.1.0" />
<PackageReference Include="Microsoft.Owin.Security" Version="3.1.0" />
<PackageReference Include="Microsoft.Owin.Security.Jwt" Version="3.1.0" />
<PackageReference Include="Microsoft.Owin.Security.OAuth" Version="3.1.0" />
<PackageReference Include="Microsoft.QualityTools.Testing.Fakes" Version="16.11.230815" />
<PackageReference Include="Microsoft.Web.Infrastructure" Version="1.0.0" />
<PackageReference Include="Nancy" Version="2.0.0" />
<PackageReference Include="Nancy.Bootstrappers.Ninject" Version="1.4.1" />
<PackageReference Include="Nancy.MSOwinSecurity" Version="2.0.0" />
<PackageReference Include="Nancy.Owin" Version="2.0.0" />
<PackageReference Include="Nancy.Validation.FluentValidation" Version="2.0.0" />
<PackageReference Include="NEventStore" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="Ninject" Version="3.3.4" />
<PackageReference Include="Ninject.Extensions.ChildKernel" Version="3.3.0" />
<PackageReference Include="Owin" Version="1.0.0" />
<PackageReference Include="OwinHost" Version="3.1.0" />
<PackageReference Include="RabbitMQ.Client" Version="6.2.2" />
<PackageReference Include="RavenDB.Client" Version="5.3.1" />
<PackageReference Include="Serilog" Version="2.10.0" />
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Loggly" Version="5.4.0" />
<PackageReference Include="Serilog.Sinks.PeriodicBatching" Version="2.3.0" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="4.0.2.206221351" />
<PackageReference Include="Thinktecture.IdentityModel.Owin.ScopeValidation" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.IdentityModel" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net" />
<Reference Include="System.Runtime.Caching" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Web.ApplicationServices" />
<Reference Include="System.Web.DynamicData" />
<Reference Include="System.Web.Entity" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
</ItemGroup>
</Project>

IdentityServer4 and ASP.NET Core 2.0

I must be missing something but I cannot see it.
I have created a new 'empty' ASP.NET Core 2.0 Project
I added EF Core 2.0 and EF Core 2.0 Identity
I then try to add IdentityServer4 2.0 rc1 and I get a package restore failure with the following error message:
Error occurred while restoring NuGet packages: Sequence contains more
than one matching element
There is no code in this project so I am completely confused.
Here is the csproj file:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="IdentityServer4" Version="2.0.0-rc1-update1" />
<PackageReference Include="IdentityServer4.AspNetIdentity" Version="2.0.0-rc1" />
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.0" />
<PackageReference Include="NETStandard.Library" Version="2.0.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
Here is my call to NuGet.org from the Package Manager Console:
PM> Install-Package IdentityServer4.AspNetIdentity -Version 2.0.0-rc1
-Prerelease GET https://api.nuget.org/v3/registration3-gz-semver2/identityserver4.aspnetidentity/index.json
OK
https://api.nuget.org/v3/registration3-gz-semver2/identityserver4.aspnetidentity/index.json
484ms Restoring packages for
D:\ProtoTypes\IdentityServer4\IdentityServer4\IdentityServer4.csproj...
Install-Package : Sequence contains more than one matching element At
line:1 char:1
+ Install-Package IdentityServer4.AspNetIdentity -Version 2.0.0-rc1 -Pr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand
Time Elapsed: 00:00:03.7728514 PM>
Following are some changes that you will migrate your project to asp.net core 2.0.
Step 1:
Download asp.net core 2.0 gx64x for visual studio 2017 from the following link.https://www.microsoft.com/net/download/core
Step 2:
Download from Nuget packages or from package manager console
1-Install-Package IdentityServer4 -Version 2.0.0
2-Install-Package IdentityServer4.AspNetIdentity -Version 2.0.0-rc1-update2
Step 3:
Update Some Code in Csproj file.
Before:
netcoreapp1.1
After:
netcoreapp2.0
Before:
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.1" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" />
After:
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
Before:
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="1.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
 
After:
<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.Extensions.SecretManager.Tools" Version="2.0.0" />
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
Step 4:
Update in Program.cs Class
Before:
public static void Main(string[] args)
{
    var host = new WebHostBuilder()
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .UseStartup()
        .Build();
 
    host.Run();
}
 
After:
public static void Main(string[] args)
{
    BuildWebHost(args).Run();
}
 
public static IWebHost BuildWebHost(string[] args) =>
    WebHost.CreateDefaultBuilder(args)
           .UseStartup()
           .Build();
Step 5:
Update in StartUp.cs
services.AddIdentityServer()
.AddDeveloperSigningCredential()
.AddInMemoryPersistedGrants()
.AddInMemoryIdentityResources(Config.GetIdentityResources())
.AddInMemoryApiResources(Config.GetApiResources())
.AddInMemoryClients(Config.GetClients())
.AddAspNetIdentity<ApplicationUser>();
Before:
app.UseIdentity();
After:
app.UseAuthentication();
Step 6:Changes in Manage Login ViewModel
Before:
public IList<AuthenticationDescription> OtherLogins { get; set; }
 
After:
public IList<AuthenticationScheme> OtherLogins { get; set; }
Step 7:
Changes in Manager Controller
Before:
var otherLogins = _signInManager
                  .GetExternalAuthenticationSchemes()
                  .Where(auth => userLogins
                                 .All(ul => auth.AuthenticationScheme != ul.LoginProvider))
                  .ToList();
 
After:
var otherLogins = (await _signInManager
                   .GetExternalAuthenticationSchemesAsync())
                  .Where(auth => userLogins
                                 .All(ul => auth.Name != ul.LoginProvider))
                  .ToList();
Step 8:
Change sin Login.cshtml file
Before:
var loginProviders = SignInManager.GetExternalAuthenticationSchemes().ToList();
 
After:
var loginProviders = (await SignInManager.GetExternalAuthenticationSchemesAsync()).ToList();
Before:
<button type="submit" class="btn btn-default"
        name="provider" value="#provider.AuthenticationScheme"
        title="Log in using your #provider.DisplayName account">
    #provider.AuthenticationScheme
</button>
 
After:
<button type="submit" class="btn btn-default"
        name="provider" value="#provider.Name"
        title="Log in using your #provider.DisplayName account">
    #provider.Name
</button>

System.Text.Encoding conflict with System.Runtime

After I've changed project.json to csproj I have compilation error:
error CS0433: The type 'Encoding' exists in both 'System.Text.Encoding, Version=4.0.10.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' and 'System.Runtime, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
My csproj:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.AspNetCore" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="1.1.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.1" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="5.1.3" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="1.1.0" />
<PackageReference Include="System.Text.Encoding" Version="4.3.0" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0" />
</ItemGroup>
</Project>
And the code is something like that:
using System.Text;
...
var x = Encoding.ASCII.GetBytes("xxx");
Could someone help?

Resources