EF Core Tip 1: Running your migrations when publishing

I was looking for a way to automatically update the database after a deploy. The only way I found so far to do this, is to do this in code in your Startup class.

In the Configure method, use this code to upgrade your database other than Development:


If you make sure to set the correct environment variable in the environment you’re deploying to, it will upgrade the database with your migrations.

ASP.NET Core Tip 1: Setting the environment in an Azure App Service

In ASP.NET Core there is a great new way to indicate what environment your site is running on. An environment variable has been introduced called ASPNETCORE_ENVIRONMENT. You can find the official documentation here.

Here’s how you set the environment on an Azure App Service. Select the App Service you want to configure, and scroll down to Application Settings.

Under the section App Settings, you can add or update the ASPNETCORE_ENVIRONMENT setting to the correct value. Here it is configured to have Staging as the value.

Show your version number in ASP.NET Core in 2 steps

I always find it useful when working on a project to be able to see the version number of the product somewhere. This doesn’t necessarily have to be shown to the end user later on, but when you’re deploying very often I find it very helpful.

Step 1: set your current version number

  • Right-click on your ASP.NET core web project, and select Properties
  • Go to the Package tab
  • Change the Package Version variable to the version you want
  • Save the properties, and Build the project

Step 2: Show the version number in your web application

Choose the place where you want to show your version number. You can use the following Razor code to show the version:


Podcast Review: Noah Kagan Presents

I’m always weary to add another site or podcast to my list. I’ve only got so much time to read or listen, so I try to only add really good sources.

I must admit I was a bit skeptical when I heard Noah Kagan had a new podcast. After hearing Noah advertise his podcast on the Tim Ferriss Show, I tried one episode to see if it was worth subscribing to.

The episode I chose was #10: Deep Dive on Jim Rohn’s 7 Strategies for Wealth & Happiness. I was so impressed with his podcast after listening to his episode, I subscribed at once. Some of the things you’ll learn in this episode:

  1. Use focused Goals: without a goal you will never achieve your dreams
  2. Seek knowledge
  3. Learn how to change
  4. Control your money: To have more than you’ve got, you have to become more than you are
  5. Master time
  6. Surround yourself with winners
  7. Learn how to live well

Noah has a pleasant fast-paced style of talking and has a good mix of information and opinion.

Highly Recommended.

Subscribe in iTunesSubscribe on AndroidSubscribe on Stitcher

Checkout the Podcast page including all the episode details here