Home > Mobile >  Scaffolding a MySQL view using Pomelo and .Net Core 2.1
Scaffolding a MySQL view using Pomelo and .Net Core 2.1

Time:12-09

Apparently, with .Net Core 2.1, views are now supported. I was wondering if it is possible to scaffold a view using Pomelo, and if so, what the syntax is? I tried the "table" syntax with a view but it didnt work:

dotnet ef dbcontext scaffold "Server=myserver.com;Database=myDatabase;User=userame;Password=password;" "Pomelo.EntityFrameworkCore.MySql" -t personsView -o models

It runs, but it only generates a dbContext - it doesn't generate the model.

I'm using Pomelo 2.1.1 and Visual Studio 2017 (15.7.5). My project is a .Net Core 2.1 Web API. On the back end, I have MySQL Server 5.6.30.

CodePudding user response:

Using Pomelo, you can use the following command (within the Package Manager Console) to generate the models as well as the context class:

Scaffold-DbContext [CONNECTION_STRING] Pomelo.EntityFrameworkCore.MySql -OutputDir [OUTPUT DIRECTORY] -Context [NAME OF CONTEXT CLASS] -f

  • Related