I’ve been developing in .Net since, I think, version 1.0 of the framework and now I’m just getting into .Net Core.
Mostly this is for myself, but I thought I might as well record them in a blog for others. I’m gong to record some snippets, tips and tricks as I go along.
First one is that the ADO.Net dbContext seems to be missing, so if you’re going Database First, you can’t just right-click and update to get the latest DB changes into your POCO classes. Instead, I’m using the following NuGet Package Manager command to bring my SQL Server tables into my .Net Core project.
Scaffold-DbContext ‘Data Source=.;Initial Catalog=TheCCG;Integrated Security=true;’ Microsoft.EntityFrameworkCore.SqlServer -Force -OutputDir Models
Note that you must have installed the Entity Framework Tools package already and in my case I had to restart VS 2015 Update 3 before Scaffold-DbContext was recognized.
UPDATE: Somewhere along the line with a version update, the above command started giving me an error “The term ‘Scaffold-DbContext’ is not recognized as the name of a cmdlet, function, script file, or operable program“. So I’m now uysing this on the command line:
dotnet ef dbcontext scaffold “Data Source=.;Initial Catalog=TheRSG;Integrated Security=true;” Microsoft.EntityFrameworkCore.SqlServer –output-dir Models –force