I’ve been using the user snippet feature of Visual Studio Code to make it easier to get some of the code I commonly use for EF Core into my files. For example I have C# snippets for DbContext to create a constructor overload that takes in a DbContextOptions parameter, OnConfiguring or OnModeling . I have json snippets to add in the EFCore Commands dependency and the Tools section with EF Core tools.
I finally created a github repository to share them. Since you’ll need to add the csharp snippets into your existing csharp snippets and the same with the json, i have put them into separate csharp.json and json.json files from which you can copy and past my snippets into your own.
Although the instructions are on the user defined snippets page I just linked to, the TL;DR is:
From menu, choose Code, Preferences then User Snippets
That will open a list of snippet files. Choose C# for the C# snippets and Json for the Json snippets. Paste in my snippets!
Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!
2 thoughts on “Visual Studio Code Snippets to Make Coding EF Core a Little Simpler”