https://stackoverflow.com/questions/758066/how-to-mock-controller-user-using-moq
Simply mock the ControllerContext and assign it to the controller before running the method that needs testing.
Bruce Ng's software development blog
An archive of solutions of programming problems I have faced in my career
https://stackoverflow.com/questions/758066/how-to-mock-controller-user-using-moq
Simply mock the ControllerContext and assign it to the controller before running the method that needs testing.
When trying to use the code first approach of Entity Framework Core to generate database and tables using MySQL. When running Update-Database in the package console manager, it shows an error saying table __efmigrationhistory doesn’t exists.
After digging in Stackoverflow, it seems that it’s a bug with the official MySQL connector. And at the time of this writing with this version 8.0.20 and .NET Core 3.1, this bug hasn’t been fixed. The connector is supposed to create this table for migration.
https://stackoverflow.com/a/46090571/9191495
In order to solve this problem there are two solutions
-Don’t use the official connector, use Pomelo.EntityFramework.MySql
https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql
-Alternatively create, the table yourself
CREATE TABLE `__EFMigrationsHistory`
(
`MigrationId` nvarchar(150) NOT NULL,
`ProductVersion` nvarchar(32) NOT NULL,
PRIMARY KEY (`MigrationId`)
);
It’s a waste of time, but what can one do.
When developing ASP.NET Core applications, if for some reason the breakpoints never hit when the browser tries to refresh or makes requests to the server.
One possible reason is that the responses are cached by the client, this is especially the case with static files. Use Ctrl-F5 in the browser to clear the cache. If the browser uses the data in the cache instead, there won’t be any requests to the server.
This of course applies to any other backend technologies, no requests, no breakpoint hits.
If you encounter this error, check the parameters of the action method, there may be no model binders configured for one or some of them.
If you want to change a .NET Core project Docker target, for example from Windows to Linux, edit the project file and and change the value of property <DockerDefaultTargetOS>.
Change from Windows to Linux and vice versa.