question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Option to Generate DbContent and Entities in Different Locations

See original GitHub issue

As of v2.1 EF Core tooling has a --context-dir option which allows generation of DbContext and Entities in different locations. It would be nice to have both --output-dir and --context-dir options via the UI for EFC PT.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:13 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Jun 20, 2018

I meant;

In project A, launch Power Tool, Rev Eng, select tables, select to only generate DbContext.

In project B, launch Power Tool, Rev Eng, select tables, select to only generate Entity Types.

Done

(I need the project reference, in particular for .NET Framework projects, in order to add the files.)

1reaction
tonysneedcommented, Jun 19, 2018

Yes, so instead of a single text box for “Project Path”, you would have two text boxes: “DbContext Path” and “Entities Path”. You would want to disable one or the other if they select the option to generate DbContext only or Entities only.

The user could specify just a folder name for either of these, which would indicate folders within the current project, for example, Context and Models.

Or the user could enter a relative path for the Entities Path, pointing to another project within the same solution, for example, …\MyApp.Entities. In that case, the DbContext Path would default to “.” for the local project. The beauty of this is that entities can be output to a NET Standard library, which can be referenced by a project that has repository interfaces and has no dependency on EF Core or any other persistence stack.

See this repo, which I repurposed to demonstrate the kind of project structure which separates entities from context.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scaffold-DbContext to different output folder
I'm using Scaffold-DbContext setting my Backend Project as default project to destination of model classes, however DbContext Class is always ...
Read more >
Migrations with Multiple Providers - EF Core
One way to create multiple migration sets is to use one DbContext type per provider. ... Specify the context type when adding new...
Read more >
Best Practices in Using the DbContext in EF Core
A DbContext represents a collection of entity sets or tables in your database. It allows us to write strongly-typed code against our database ......
Read more >
Generating a model from an existing database
You use the DbContext Scaffold command to generate the model. The command has two required arguments - a connection string and a provider....
Read more >
Entity Framework Core DbContext
To use DbContext in our application, we need to create the class that derives from DbContext , also known as context class. This...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found