sjh37 / EntityFramework-Reverse-POCO-Code-First-Generator

EntityFramework Reverse POCO Code First Generator - Beautifully generated code that is fully customisable. This generator creates code as if you reverse engineered a database and lovingly created the code by hand. It is free to academics (you need a .edu or a .ac email address), not free for commercial use. Obtain your licence from
https://www.reversepoco.co.uk/
Other
706 stars 229 forks source link

Settings.IncludeTableValuedFunctions = true; #519

Open BermudaLamb opened 5 years ago

BermudaLamb commented 5 years ago

Version: 2.37.4 Following the PluralSight training module. Installed the latest version of EntityFramework.CodeFirstStoreFunctions. Switched the Settings.IncludeTableValuedFunctions to true, and saved the file. The IQueryable method for CsvToInt shows up in both conext files (Nothwind and Fake). However, the class CsvToIntReturnModel was not generated. This is the output from EF Reverse POCO Generator:

// ------------------------------------------------------------------------------------------------
// This code was generated by EntityFramework Reverse POCO Generator (http://www.reversepoco.com/).
// Created by Simon Hughes (https://about.me/simon.hughes).
//
// Do not make changes directly to this file - edit the template instead.
//
// The following connection settings were used to generate this file:
//     Configuration file:     "NorthwindDemo\App.config"
//     Connection String Name: "Northwind"
//     Connection String:      "Data Source=local\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True;Application Name=Northwind demo;"
// ------------------------------------------------------------------------------------------------
// Database Edition        : Express Edition (64-bit)
// Database Engine Edition : Express
// Database Version        : 14.0.2027.2
smarteez17 commented 5 years ago

@sjh37 - I am also having this issue please tag me as well when this issue is fixed

smarteez17 commented 5 years ago

@BermudaLamb Is your Table ValuedFunction calling a scalar-valued function? I think that where the problem is

sjh37 commented 5 years ago

I have added scalar-valued functions to the new (not yet released) v3 of the generator. Code available on DropBox.

smarteez17 commented 5 years ago

@sjh37 thank you so much do you know when v3 will be released ?

sjh37 commented 5 years ago

In about 3 weeks time all being well.

smarteez17 commented 5 years ago

@sjh37 thank you when it comes out will there be notes on how to update your current version to new version

sjh37 commented 5 years ago

@smarteez17 I'll make sure there is. Thanks for the reminder!

smarteez17 commented 5 years ago

@sjh37 - I looking at the .tt file i searching for scalar-valued to find the setting and there no results am i missing a step ?

sjh37 commented 5 years ago

@smarteez17 The scalar-valued function are still under FilterSettings.IncludeTableValuedFunctions at the moment. I'm changing that today so it's separate 👍

sjh37 commented 5 years ago

That is all done now. Latest code in DropBox.

sjh37 commented 5 years ago

@BermudaLamb Playing around with the settings and different database, I noticed one of the table valued function return models was not being returned if IncludeSynonyms = false, so try setting that to 'true'.

smarteez17 commented 5 years ago

@sjh37 I went through my setting and looked for it in the new file. I cant fine the following

  1. EntityClassesModifiers 2.UsePascalCase 3.UseDataAnnotation 4.TableRename setting

where do I find them ? thank you for IncludeScalarValuedFunctions setting

sjh37 commented 5 years ago

I've not yet pulled in examples of all the settings into the tt file, only the core essentials, however I'm suspecting I should do that now as a few others have suggested the same thing to make it easier to get going.

In your tt file, add in:

Settings.UsePascalCase = true;
Settings.EntityClassesModifiers        = "public"; // "public partial";
Settings.ConfigurationClassesModifiers = "public"; // "public partial";
Settings.DbContextClassModifiers       = "public"; // "public partial";
Settings.DbContextInterfaceModifiers   = "public"; // "public partial";
Settings.ResultClassModifiers          = "public"; // "public partial";

UseDataAnnotation has been removed for now. Data annotations are not capable as fluent configurations, and so often ended up with both being generated.

Near the top of EF.Reverse.POCO.v3.ttinclude Look into the class SingleContextFilter There you will find TableRename. I'm going to change a lot of these so that they can be actioned from within your tt file, rather than editing the ttinclude file.

smarteez17 commented 5 years ago

@sjh37 - thanks for that I will wait for you to release this version . so i can go through all the notes and make sure i doing this right :) Maybe for the next version you can add a setting for renaming views, thats what i am using the table rename for ( if its a view add the word view to it ) - I not sure how to using the SingleContextFilter can you explain a bit more

"UseDataAnnotation has been removed for now. Data annotations are not capable as fluent configurations, and so often ended up with both being generated." is this a setting i need somewhere? in my Entities folder is i have Data annotations set to true my application doesnt work without it ( in all my other folders Configuration, Context and Interfaces i got Data annotations set to false )

Lastly what addon or something do I need to used in vs2019 to make reading the .tt file as currently everything is white and i have to look for everything

sjh37 commented 5 years ago

For reading tt files, I use a Resharper plugin called fortea.

You should not need data annotation at all to make it work. I would be interested to hear why it's not working without it.

smarteez17 commented 5 years ago

@sjh37 I also used the data annotation generated in Entities to create my domain class is there any possibly to include that option in the new version

sjh37 commented 5 years ago

@smarteez17 Possibly. I want to get it out there with 100% accuracy with fluent. Then I want to add support for Oracle, Postgres and MySql. Then I could look again at DataAnnotations.

BermudaLamb commented 5 years ago

Will you also be providing support for Snowflake?

On Sat, Oct 19, 2019, 8:11 AM Simon Hughes notifications@github.com wrote:

@smarteez17 https://github.com/smarteez17 Possibly. I want to get it out there with 100% accuracy with fluent. Then I want to add support for Oracle, Postgres and MySql. Then I could look again at DataAnnotations.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/issues/519?email_source=notifications&email_token=ABNFN3YZON6F6LM7RXUYY53QPMBQFA5CNFSM4IHVA3K2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBXPH3Y#issuecomment-544142319, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNFN36AQG56F7FVZMZILRTQPMBQFANCNFSM4IHVA3KQ .

sjh37 commented 5 years ago

Hi @BermudaLamb Once Oracle, Postgres and MySql are added, which are the top databases right now, I will add support for others. However snowflake is ranked 52 at the moment, and climbing sharply.

I've made it as easy as possible to integrate new databases into the v3 generator, It all depends on how easy it is to create the SQL I need to extract the information from the new database.

In the first instance, I would install it, and contact snowflake asking their experts if they would help with the SQL I need as it might help sell more licences knowing entity framework software devs can get a head start in integrating with it.