EntityFramework-Reverse-POCO-Code-First-Generator
EntityFramework-Reverse-POCO-Code-First-Generator copied to clipboard
Poco interfaces
Add an option to create a poco interface.
The {{moustache}} template will be something like this:
{{ClassModifier}} interface I{{NameHumanCaseWithSuffix}}{{#newline}}
{{{#newline}}
{{#each Columns}}
{{#if OverrideModifier}}override {{/if}}{{WrapIfNullable}} {{NameHumanCase}} { get; {{PrivateSetterForComputedColumns}}set; }{{#newline}}
{{/each}}
{{#if HasReverseNavigation}}
{{#newline}}
{{#each ReverseNavigationProperty}}
{{Definition}}{{#newline}}
{{/each}}
{{/if}}
{{#if HasForeignKey}}
{{#newline}}
{{#each ForeignKeys}}
{{Definition}}{{#newline}}
{{/each}}
{{/if}}
{{#if EntityClassesArePartial}}
{{#newline}}
void InitializePartial();{{#newline}}
{{/if}}
}{{#newline}}
Once this is complete and the flag is set will it allow generation into separate files?
Hi @revbones-duplicate Yes it will
Does EF version 3.8.4 tt script have the ability to have each poco entity class create be able to be derived from a custom interface?
Does EF version 3.8.4 tt script have the ability to have each poco entity class create be able to be derived from a custom interface?
@stevensrf11 Yes it does. Here is an example of adding different base classes depending on name
// Use the following function if you need to apply additional modifications to a table
// Called just before UpdateColumn
Settings.UpdateTable = delegate(Table table)
{
// To add a base class to a table based on column names. Also see Settings.UpdateColumn below.
var tracking = new List<string> { "createdby", "createdon", "modifiedby", "modifiedon" };
var replicate = new List<string> { "uniqueid", "hrid"};
if (table.Columns.Any(x => tracking.Contains(x.NameHumanCase)))
table.BaseClasses = " : TrackingEntity";
if (table.Columns.Any(x => replicate.Contains(x.NameHumanCase)))
table.BaseClasses = " : ReplicateEntity";
// To add attributes
table.Attributes.Add("[Serializable]");
};
That example made no sense to me.
I want each poco entity class to derive IDLEntity.
How would I modify the tt script to do this
Sent: Friday, November 10, 2023 at 10:20 AM From: "Simon Hughes" @.> To: "sjh37/EntityFramework-Reverse-POCO-Code-First-Generator" @.> Cc: "stevensrf11" @.>, "Mention" @.> Subject: Re: [sjh37/EntityFramework-Reverse-POCO-Code-First-Generator] Poco interfaces (Issue #789)
Does EF version 3.8.4 tt script have the ability to have each poco entity class create be able to be derived from a custom interface?
@stevensrf11 Yes it does. Here is an example of adding different base classes depending on name
// Use the following function if you need to apply additional modifications to a table
// Called just before UpdateColumn
Settings.UpdateTable = delegate(Table table)
{
// To add a base class to a table based on column names. Also see Settings.UpdateColumn below.
var tracking = new List
// To add attributes
table.Attributes.Add("[Serializable]");
};
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
I understand this from a former post
Func<Table, string> WritePocoBaseClasses = t => { if (t.NameHumanCase== "Contact" || t.NameHumanCase== "Customer") { var r = new BaseClassMaker("BaseClass"); return r.ToString(); } }
But I have no clue what any of that code you shown below does.
What does this do and why would I want a new list?
Does creating these new variable mess up anything or change anying that works already?
why the use of the hard coded string what do the hard code string mean?
var tracking = new List
Is this suppose to create two base classes based for a table that is named by one if the string is tracking and replicate variables?
if (table.Columns.Any(x => tracking.Contains(x.NameHumanCase))) table.BaseClasses = " : TrackingEntity";
if (table.Columns.Any(x => replicate.Contains(x.NameHumanCase))) table.BaseClasses = " : ReplicateEntity";
Sent: Friday, November 10, 2023 at 10:20 AM From: "Simon Hughes" @.> To: "sjh37/EntityFramework-Reverse-POCO-Code-First-Generator" @.> Cc: "stevensrf11" @.>, "Mention" @.> Subject: Re: [sjh37/EntityFramework-Reverse-POCO-Code-First-Generator] Poco interfaces (Issue #789)
Does EF version 3.8.4 tt script have the ability to have each poco entity class create be able to be derived from a custom interface?
@stevensrf11 Yes it does. Here is an example of adding different base classes depending on name
// Use the following function if you need to apply additional modifications to a table
// Called just before UpdateColumn
Settings.UpdateTable = delegate(Table table)
{
// To add a base class to a table based on column names. Also see Settings.UpdateColumn below.
var tracking = new List
// To add attributes
table.Attributes.Add("[Serializable]");
};
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
Ok I got it.
I see all I have to do is set table.BaseClasses equal to a class that derives from the interface.
Thanks
Steven
Sent: Friday, November 10, 2023 at 10:20 AM From: "Simon Hughes" @.> To: "sjh37/EntityFramework-Reverse-POCO-Code-First-Generator" @.> Cc: "stevensrf11" @.>, "Mention" @.> Subject: Re: [sjh37/EntityFramework-Reverse-POCO-Code-First-Generator] Poco interfaces (Issue #789)
Does EF version 3.8.4 tt script have the ability to have each poco entity class create be able to be derived from a custom interface?
@stevensrf11 Yes it does. Here is an example of adding different base classes depending on name
// Use the following function if you need to apply additional modifications to a table
// Called just before UpdateColumn
Settings.UpdateTable = delegate(Table table)
{
// To add a base class to a table based on column names. Also see Settings.UpdateColumn below.
var tracking = new List
// To add attributes
table.Attributes.Add("[Serializable]");
};
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>
@stevensrf11
Settings.UpdateTable = delegate(Table table)
{
table.BaseClasses = " : IDLEntity";
};
Thank you
Sent: Friday, November 10, 2023 at 7:31 PM From: "Simon Hughes" @.> To: sjh37/EntityFramework-Reverse-POCO-Code-First-Generator @.> Cc: stevensrf11 @.>, Mention @.> Subject: Re: [sjh37/EntityFramework-Reverse-POCO-Code-First-Generator] Poco interfaces (Issue #789)
@stevensrf11
Settings.UpdateTable = delegate(Table table) { table.BaseClasses = " : IDLEntity"; };
-- Reply to this email directly or view it on GitHub: https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/issues/789#issuecomment-1806226016 You are receiving this because you were mentioned.
Message ID: @.***>