EntityFrameworkCore.Generator
EntityFrameworkCore.Generator copied to clipboard
Add support for multiple DbContext-classes
I'm using efg
to generate two different DbContexts, one regular read/write and a second one for read only access.
For this I have two separate .yml-configuration files and I run using efg -f standard-context.yml
The problem is that when I do this, the generator finds the read only DbContext first, and tries to rename it to the standard context name.
I Rename Context Class'PmMarknadSyncDbContext' to 'MarknadReadOnlyDbContext'.
My solution today is to do the generation outside of my project folder and the manually replace the files. But then I loose changes I made outside of #region
I Thing it's always best to have a project for each database, separated from the main application project
I Thing it's always best to have a project for each database, separated from the main application project
hmm, I do have a separate project for my database. But I use two different contexts, and one of them is very small (only one table at the moment, might grow a bit in the future). I could separate them in two different projects but I'm feeling it will add unnecessary overhead and complexity.
I'll see if i can come up with a way to specify the DbContext class in the yml file. I've run into the same issue, but slightly different usage.
Hello Multiple DbContext-classes is also a nice-to-have feature for me. I have a database with 8 schemas. The solution has a separate "*.Data" project with database context for each of them. And I would like to generate a separate database context for each schema. I tried to modify configuration file using "Table.Schema" like this: context: name: '{Table.Schema}Context' baseClass: DbContext propertyNaming: Plural namespace: '{Project.Namespace}.Data' directory: '{Project.Directory}\Data' document: false
Expected to have 8 files, but as a result, only one "Context.cs" file was generated in "Data" directory.