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.

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

That generates the dbcontext and classes for the tables, but it does not generate any classes for views.
@PinpointSolutions of course, that is the behavior in .NET since MVC3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.