Scaffolding a MySQL view using Pomelo and .Net Core 2.1
Asked Answered
M

1

6

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.

Minium answered 18/6, 2018 at 8:12 Comment(0)
S
11

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

Scincoid answered 7/8, 2018 at 11:27 Comment(2)
That generates the dbcontext and classes for the tables, but it does not generate any classes for views.Prizewinner
@PinpointSolutions of course, that is the behavior in .NET since MVC3Scrutineer

© 2022 - 2024 — McMap. All rights reserved.