This blog article illustrations how to use Entity Framework Core with SQL Server. The sample that you found here https://docs.microsoft.com/en-us/ef/core/get-started/?tabs=visual-studio/?WT.mc_id=DP-MVP-36769 is using SqlLite.
To use SQL Server instead of
Install-Package Microsoft.EntityFrameworkCore.Sqlite
You need to install
Install-Package Microsoft.EntityFrameworkCore.sqlserver
Change the Model.cs accordingly.
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
public string conn = “data source=.;initial catalog=blogging;integrated security=True”;
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlServer(conn);
}
public class Blog
{
public int BlogId { get; set; }
public string Url { get; set; }
public List<Post> Posts { get; } = new List<Post>();
}
public class Post
{
public int PostId { get; set; }
public string Title { get; set; }
public string Content { get; set; }
public int BlogId { get; set; }
public Blog Blog { get; set; }
}
I altered a bit the program.cs as well as below.
static void Main()
{
using (var db = new BloggingContext())
{
// Create
Console.WriteLine(“Inserting a new blog”);
db.Add(new Blog {BlogId=1, Url = “http://blogs.msdn.com/adonet” });
db.SaveChanges();
// Read
Console.WriteLine(“Querying for a blog”);
var blog = db.Blogs
.OrderBy(b => b.BlogId)
.First();
// Add Post
Console.WriteLine(“Updating the blog and adding a post”);
db.Add(new Post
{
PostId = 1,
Title = “Hello World”,
Content = “I wrote an app using EF Core!”,
BlogId = 1
}
);
db.SaveChanges();
// Delete
Console.WriteLine(“Delete the blog”);
db.Remove(blog);
db.SaveChanges();
}
}
You should follow the rest of the step on the docs.microsoft link. Issue the comment in Visual Studio.
Install-Package Microsoft.EntityFrameworkCore.Tools
Add-Migration InitialCreate
Update-Database
And put the line in csproj file after the TargetFramework property,
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
You will see the below screen when you run the program.

Source code download: https://github.com/chanmmn/EFCoreSqlServer