Skip to content

Instantly share code, notes, and snippets.

@pedrocss
Last active July 12, 2017 11:46
Show Gist options
  • Save pedrocss/df0688b5eac13115f6ef1b10deebf1a1 to your computer and use it in GitHub Desktop.
Save pedrocss/df0688b5eac13115f6ef1b10deebf1a1 to your computer and use it in GitHub Desktop.
Como gerar os Models e Context no .NET CORE utilizando o EF Core.
  1. Tools –> NuGet Package Manager –> Package Manager Console
  2. Execute o comando scaffold.txt no projeto MoonData (Altere o server, password, userID.

Scaffold-DbContext -Connection 'Server=tcp:.database.windows.net,1433;Initial Catalog=dataTech;Persist Security Info=False;User ID=;Password=;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;' -Provider Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Verbose -Force

  1. Se tudo der certo os Models serão atualizados e inclusive o dataTechContext;
  2. Adicione o construtor no dataTechContext:

public dataTechContext(DbContextOptions<dataTechContext> options) : base(options) { }

Tutorial baseado no ASP.NET Core - Existing Database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment