(MVC) MVC (2020)

Transform application from ancient MVC Web API technology to Net Core 3.1 (step-by-step guide)

This notes not finished, because I write down this notes for himself, for future similar project and current transformation is not finished yet.

I was created empty NET Core project and simple moving old code to new project. After I made this preparation, I receive about 1400 errors. Oh, my god, this mission impossible, I thought...




But day after day I was climbing to my Everest and below I listed a steps of this transformation.



1. New package reference.

Firstly need to add all packages from one version. This was be



In my case this was not be a simple and automatic job, for example some Net. Framework library does not exist in NET Core, therefore I must be write some library by my own hand, for example for this project I wrote library for RFC4648 Base32 EncoderDecoder - VB.NET NET.CORE 3.1 RFC4648 Base32 EncoderDecoder - Download from: [MyServer], [Github], [Nuget]



2. Remove deprecated method.

However main point of first step to rich successful compilation was be step to remove deprecated methods. Microsoft create huge list of changing even in in minor version of their framework - for example Need to be very carefully because any helping systems will be always propose you ancient deprecated methods, for example from 2.2 to 3.1.

First pretty step is rename ApiController to ControllerBase. When controller is appears a lot of various task is appears immediately. At common Microsoft permanently renamed any own method and property and moving it from one library to another. For Example ResponseType was be renamed to ProducesResponseType and HttpStatusCode to StatusCodes and new definition was be moving to maximum unexpected place. I can not provide all screens, but believe me, in Net Core MS change any possible and impossible methods convenient to programmers, for example OutputCache was be renamed to ResponseCache, VaryByParam was be renamed to VaryByHeader, Request.Headers was be moving to unexpected place and was be deleted from this class convenient interfaces and even was be deleted HttpContext.Current at all!

Why Microsoft permanently doing these terrible renaming, deleting and hiding wellknown methods to unexpected namespaces? My assumption this unexpected moving and renaming is simplest way to increase price of any software for end-user and this Microsoft policies induce higher price of Microsoft as leadership software developer company and induce growing MS stock in stock market. It's a not a news that MS a great bull in stock exchange market, but this practice is so disgusting for programmers.



3. Inject dependency.


Next step need to add constructor to each controller, to inject Ilogger and dbContext to each controller. And than need to change access to DB, in MVC pattern to accessing DB looks like line 16 in right part, all this code need to change to accessing DB through DI-container.



Next step need to configure Logger and inject DB context in Configure method of StartUp class. Server logging is a important part of core, read my this article about that How to debug SignalR application in Net Core 3.1



4. Accessing for data.

In Net Core common pattern of EF was been kept - Entity Framework missing FAQ (Part 4). From EF Code First class definition to WebAPI2 on VB.NET, but many function of EntityFramework has been changed, for example in runtime was disappear method SEED and in Visual Studio also disappear commands Migrate and other. Also has been added most popular DB provider in Net Core Microsoft.EntityFrameworkCore.InMemory (and other). Therefore new pattern to work with data in NET Core became look as in the screens below.



And this is screen before I deployed site to test Linux environment with InMemoryDatabase.



5. Changing work pattern with UserContext and HttpHeaders.

Also in Net code Microsoft has been deleted always presented parts of AAA, for example User.GetUserId - Why? I don't know why Microsoft permanently deleted in each new version of Net convenient and useful parts of previous framework. Therefore I must be write a lot various extension to restore useful and convenient for all programmers functions always presented in previous version of NET, for example



6. Delete various trash from previous programmer.

Style of previous programmer is really trash. I don't have time to describe all bug in his mind, I think is enough four his significant style of programming:

7. Moving Authentication to Identity server.

Of course most unstable part of Microsoft is Authentication and Authorisation. At common it a pretty simple idea and each programmer can be write Authorisation library during one day. For example I has written AU own library for any MS technology what exist since 2002 year. For example this is my AU library for classic ASP.NET - AspNet_UserManager - ?????????????????? ?????????? ?????? ???????????????????? ????????????????????????????., this is my own AU library for WCF Protect WCF service by password, this is my standard part of MVC project authorisation code ???????????????????? ?????????????????????? ???????????? ?????? ?????????? ????????????., but stupid Microsoft do full changing Authentication and Authorisation even inside one technology stack.

As a result of this Microsoft scam, I must be rewriting even simplest code, for example this is password changing code. Why need to be changing in MS even password changing class.



Is it renaming and deleting is some kind of any progress in IT-industry or just stupid trash and scam from Microsoft? Why I must be full rewrite even password changing code? No,no,no, of course no, this is not an any kind of progress in IT industry, this is only trash and scan from Microsoft to increase price of any kink of software, because MS is greatest and stupid bull in IT industry.


8. SignaR

Most dangerous and unstable part of Microsoft framework is SignalR library. I don't understand what this gay David Fowler thinking about yourself and yourlife, is he able to look forward to one tiny step? is he ready to create software without removing and discarding any your own existing method in new version? Or he is only stupid nigger, who create full new software each day from scratch and absolutely forget what about what he was thinking yesterday.

As I understand, when I will finish this project, SignalR library will be full changing again, therefore to rich successful compilation I must be in first step create a stub for SignalR.



9. OpenAPI specification of microservices.

Whan I was rich successful compilation my next goal was be systematize all function in my server side. I has been set route attribute in each actions and than define service and endpoint of swagger.



In my case I was receive a lot, really a lot various API functions and data structures



I like opportunity to show and spread Json API specification to other developer without access to site.



10. Create API definition for frontend.

Than I was create a specification for connect frontend to API. In my case frontend was be in Blazor technology. Nswag studio also created a lot of errors, but its was a simple task to fix it.



11. Set different port to API and frontend.



12. Create authentication with new Net core pattern.



13. Change frontend cookie AU to JWT in order to call microservices.

14. Create project Admin panel.

This is my common template for creating Blazor Admin Panel.

15. Create Users manager.



16. Create ApiTester.



17. Transform database from MsSQL to MySQL.

This process I was detail described in page Transform Database from MsSQL to MySQL (Net Core EF DbFirst, Scaffold-DbContext, Read Db Schema, Move Users and data, EF SQL trace)


18. Change data access mode for Pomelo.MySQL.

EF DataProvider for MS SQL allow working in MASR mode, multiple SQL request in one thread simultaneously, but EF provider for MySQL is not allow many SQL command in the same thread, therefore construction like IENumerable before cyrcle is impossible. Therefore need to add to line 55 or 57 ToList().



19. Create showing database form.



20. Tune Nginx endpoint for frontend and API.

In this case my Nginx listen two ports 5000 and 6000.



21. Deploy server side application to Linux hosting.

This process I was detail described in page Deploy ASP.NET Core application from scratch (install and tune SSH/VNC/FTP/NGINX/Daemon), in this case I was repeated the same procedure.





Comments ( )
<00>  <01>  <02>  <03>  <04>  <05>  <06>  <07>  <08>  <09>  <10>  <11>  <12>  <13>  <14>  <15>  <16>  <17>  <18>  <19>  <20>  <21>  <22>  <23
Link to this page: //www.vb-net.com/TransformWebapiToCore/Index.htm
<SITEMAP>  <MVC>  <ASP>  <NET>  <DATA>  <KIOSK>  <FLEX>  <SQL>  <NOTES>  <LINUX>  <MONO>  <FREEWARE>  <DOCS>  <ENG>  <CHAT ME>  <ABOUT ME>  < THANKS ME>