I was looking into how to handle upserts with ef core and came across this: The Update method normally marks the entity for update, not insert. However, if the entity has a auto-generated key, and no key value has been set, then the entity is instead automatically marked for insert. https://docs.microsoft.com/en-us/ef/core/saving/disconnected-entities#saving-single-entities To be honest, I'm… Continue reading ef core upsert
Category: mssql
How to use dotnet ef dbcontext scaffold to create entity classes from an existing database
Setup and commands may vary depending on the OS you are using and what IDE you want to work in. I'm on a Windows 10 machine using Visual Studio Code so this tutorial will be using the cli tools and commands. I'm using the AdventureWorks database I restored to a docker container in the previous… Continue reading How to use dotnet ef dbcontext scaffold to create entity classes from an existing database
Restore a SQL Server database in Docker
In this post I'll show how we can restore a database when starting up a docker container for the first time. First in the Dockerfile, we will need to make sure we are moving the backup into the container as a part of the build process. In my Dockerfile, I'll create a backup folder and… Continue reading Restore a SQL Server database in Docker
Using SQLCMD to check if SQL is running
In my previous post we use a simple sleep command to wait out the sql start up and prevent our sql commands from executing too early. I wanted to see if I could write a better check for this and not have to hope my guess at a sleep time is correct. I was able… Continue reading Using SQLCMD to check if SQL is running
Running mssql on docker
Here is a quick walk through to setup a simple MSSQL instance on docker and initialize the instance with a data. First we will setup a few scripts to startup sql, create a database and initialize it with data. entrypoint.sh #start SQL Server, start the script to create/setup the DB /init.sh & /opt/mssql/bin/sqlservr init.sh --… Continue reading Running mssql on docker
