ASP.NET Core with Entity Framework Core – ASPNETCORE_ENVIRONMENT

This is another one, Figure 1, that just kind of happened because I dropped my database.  Once I re-created the database and my ASP.NET Core application could access it, all was back to normal.

image

Figure 1, ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.

Error.
An error occurred while processing your request.
Development Mode

Swapping to Development environment will display more detailed information about the error that occurred.

Development environment should not be enabled in deployed applications, as it can result in sensitive information from exceptions being displayed to end users. For local debugging, development environment can be enabled by setting the ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.

Most likely because I had the environment variable ASPNETCORE_ENVIRONMENT set to Development as seen in Figure 2.

image

Figure 2, ASPNETCORE_ENVIRONMENT environment variable to Development, and restarting the application.

And also there is some code in the default public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) method in the Startup.cs file which checks for this.

if (env.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
    app.UseBrowserLink();
}
else
{
    app.UseExceptionHandler("/Home/Error");
}

Learn more about ASPNETCORE_ENVIRONMENT here.

See my other ASP.NET Core articles here.