Skip to content

Instantly share code, notes, and snippets.

@MirKml
Last active April 8, 2018 12:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save MirKml/3694c916fa4d869818226b19c918f0bd to your computer and use it in GitHub Desktop.
list of useful commands for .net core
  • Create empty MVC project.
$ dotnet new mvc -n MyWebProject

Support for entity framework core for current database

For example for sqlite database. All dotnet commands must be executed under current dotnet project directory.

  1. add nuget package for EF Core provider for database type (sqlite, mysql, ...)
$ dotnet add package Microsoft.EntityFrameworkCore.Sqlite
  1. add reference into MyWebProject.csproj for command line tools plugin for entity framework core commands. It's new item under ItemGroup element.
<ItemGroup>
  <DotNetCliToolReference Include .... />
  <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
</ItemGroup>
  1. add entity framework core design package and restore project according .csproj changes
$ dotnet add package Microsoft.EntityFrameworkCore.Design
$ dotnet restore

It's necessary to have the correct versions for all these Microsoft.EntityFrameworkCore.* packages

  1. Generate the models from the current database
$ dotnet ef dbcontext scaffold "Filename=../blog.sqlite" Microsoft.EntityFrameworkCore.Sqlite -o Models
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment