Scaffold-DbContext (EF Core Tools) throws ‘Instance failure’ exception

I think you need to change your instance name. For example : Scaffold-DbContext “Server=PC\SQLEXPRESS;Database=***;User ID=sa;Password=****” Microsoft.EntityFrameworkCore.SqlServer -OutputDir model So your instance in this case is : PC\\SQLEXPRESS. This instance should be like this : .\SQLEXPRESS

what is major difference between dotnet publish and dotnet pack

dotnet pack – Produces a NuGet package of your code. That is the key difference – this will enable to publish to http://nuget.org, or to a nuget server that can be pulled down by other developers, or even for use with Octopus Deploy. dotnet publish – Produces a .NET framework-dependent or self-contained application. Keyword is … Read more

Routes in ASP.net Core API

Try this. You can put a common route prefix on the controller. [Route(“api/[controller]”)] public class BXLogsController : Controller { //GET api/BXlogs/id/blah [HttpGet(“ID/{id}”, Name = “GetL”)] public IActionResult GetById(string id) { … } //GET api/BXlogs/api/blahapi [HttpGet(“API/{apiname}”, Name = “GetLAPI”)] public IActionResult GetByAPI(string apiname) { … } } read up on attribute routing here Routing to Controller … Read more

Change or rename a column name without losing data with Entity Framework Core 2.0

EF Core creates its migrations by comparing your models to the current database snapshot (a c# class). It then uses this to create a migration file you can review. However, EF Core cannot always know if you replaced this column or created a new column. When you check your migration file, make sure there are … Read more

NLog configuration in appsettings.json instead of nlog.config in .NET Core

Yes, this is possible but has a minimum version requirement. You must be using NLog.Extensions.Logging >= 1.5.0. Note that for ASP.NET Core applications this will be installed as a dependency if you install NLog.Web.AspNetCore >= 4.8.2. You can then create an NLog section in appsettings.json and load it with the following code: var config = … Read more

How to use Serilog in .NET Core Console app

I’m not sure about builder.SetMinimumLevel (it doesn’t use the Serilog enum). We set the logger level when creating the LoggerConfiguration object. Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console(restrictedToMinimumLevel: LogEventLevel.Debug) // restricted… is Optional (…) .CreateLogger(); BTW. It’s worth pointing out the following section from Configuration Basics Logger vs. sink minimums – it is important to realize … Read more

What is the simplest way to run a single background task from a controller in .NET Core?

You have the following options: IHostedService classes can be long running methods that run in the background for the lifetime of your app. In order to make them to handle some sort of background task, you need to implement some sort of “global” queue system in your app for the controllers to store the data/events. … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)