.net framework (4.6.2) migration .net core (2.2) summary

1. Create EF library, while this item is provided (use of Scaffold-DbContext -tables command) to initiate entry, installed two packets
  . 1) .Microsoft.EntityFrameworkCore.Tools
  2) .Pomelo.EntityFrameworkCore.MySql (this a third-party middleware ef mysql)

  Scaffold-DbContext -Force "Server=127.0.0.1;User Id=root;Password=123456;Database=test" -Provider "Pomelo.EntityFrameworkCore.MySql" -UseDatabaseNames -OutputDir       DataModels -ContextDir DataModels -Context TESTDbContext

Reference: https://www.cnblogs.com/DNLi/p/9524976.html 

          https://www.cnblogs.com/adandelion/p/10529788.html

2. To achieve HttpContext

Need to reference: using Microsoft.AspNetCore.Http;

///  <Summary> 
/// custom execution context
 ///  </ Summary> 
public  static  class HttpContextCustomize
{
    private static IHttpContextAccessor _httpContextAccessor;

    public static void Configure(IHttpContextAccessor httpContextAccessor)
    {
        _httpContextAccessor = httpContextAccessor;
    }

    public static HttpContext Current
    {
        get
        {
            return _httpContextAccessor.HttpContext;
        }
    }
}
HttpContextCustomize

Call: HttpContextCustomize.Current

 3. Processing web.config configuration file

1) First introduced in the solution Nuget the System.Configuration.ConfigurationManager
2). Import web.config file to the root directory of the project, and the name changed to app.config. Because the nature of the project is .NET Core Console Application
3) removal of config content regardless of the configuration and needs, mainly <system.web>, <system.webServer> and <system.codedom> tag and other typical asp.net

Reference: https://www.cnblogs.com/mantgh/p/7425113.html

4.MemoryCache bug fixes

 Add namespace references to Microsoft.Extensions.Caching.Memory, it provides a .NET Core MemoryCache default class implementation, as well as new memory cache API

Reference: https://www.jb51.net/article/122190.htm

5. How to use Unity .net framwork of (Microsoft.Practices.Unity)?

 services.AddScoped<IUnitOfWork, UnitOfWork>();

Reference: https://stackoverflow.com/questions/53562269/unity-framework-in-net-core

6. [FromQuery] Alternatively [FromUri]

 

Guess you like

Origin www.cnblogs.com/allenhua/p/12104658.html