EntityFramework-Reverse-POCO-Code-First-Generator icon indicating copy to clipboard operation
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard

How can I get the filenames and class names to be schema.TableName

Open nick5454 opened this issue 4 years ago • 1 comments

lets say I have a table ( Ef6, .net framework 4.8 )

[foo].[Bar] where schema is "foo" and the table is "Bar"

How can I change the class files produced to be

filename: foo.Bar.cs

class declaration:

namespace Project.Defaultnamespace {
    namespace foo {
        public class Bar {
            ...

Any help would be greatly appreciated

nick5454 avatar May 12 '21 18:05 nick5454

It's not that straight forward, so would require some work.

A partial solution:

In your <database>.tt settings file set

Settings.PrependSchemaName = false;

Search for and change

public CodeOutput GeneratePoco(Table table)
{
    var filename = table.NameHumanCaseWithSuffix() + Settings.FileExtension;

to

public CodeOutput GeneratePoco(Table table)
{
    var filename = table.Schema.NameHumanCase + "." + table.NameHumanCaseWithSuffix() + Settings.FileExtension;

This names the files correctly, although you may want to do something with "dbo" schema.

Next would be to sort out the namespace, which requires more work on my part. I would start with adding a namespace field to the Table class, and work from there. I'll have to leave this as a todo item as it requires some time to resolve.

sjh37 avatar May 14 '21 11:05 sjh37