Closed audacity76 closed 4 years ago
Ah yes, good catch. If you like, you can submit a fix with a PR, or I can also do it.
I'll try to provide a PR...
Thank you! Be sure to carefully follow the Contributing Guidelines: https://github.com/TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars/blob/master/.github/CONTRIBUTING.md
Alright, I'll try my best to follow the guidelines!
What happens to the names of the DbSets if there is the same table (name) in different schemas? I can change the DbSet's type and prepend the namespace so no problem there but what about the DbSet's name?
public virtual DbSet<SomeSchema.Item> Items { get; set; }
public virtual DbSet<OtherSchema.Item> Items { get; set; }
Maybe the EntityNameTransformer
could provide different names then but currently it cannot recognize the entities schema...
@audacity76 Yeah , totally the stuff my mind didn't want to let me consider when I made the PR for EnableSchemaFolders ; plus it will get annoying in the using section too...
Best to put "schema" as a variable sent to the template for;
Then alter the templates to have schema added conditionally (in the appropriate places/uses) on EnableSchemaFolders being true
such that the Set names become:
public virtual DbSet<Schema.Item> Schema_Items { get; set; }
Alternately it could be changed in the class name too and be :
public virtual DbSet<Schema_Item> Schema_Items { get; set; }
(but then it wouldn't need another namespace)
I say put it in the template, because I personally don't want the above, but I can understand others would want it.
I would agree to supply schema name in the template data. But don’t alter the hbs templates. Instead, if EnableSchemaFolders is true, prefix then model class name with the schema namespace.
@tonysneed So no namespace change? Otherwise would still need to alter hbs for "using" statements in "Imports" of entities and context...
Since the namespace for classes in a folder is nested within the parent namespace, if you just prefix the model class name with the folder name, it should all just work: public virtual DbSet<Schema.Item>
.
Ok, I'll prefix the model type with the schema name and supply the schema in the templates. So everybody can choose there own DbSet name. So for now the names stay the same which is okay if there are no duplicate table names.
Could take a while for the PR as I'm not at work this week.
Hi,
putting the entities into folders is great but the namespace should follow. If so, you can have the same table (name) in different schemas.
By the way the Docs example notes EnableSchemaFolders two times: