Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can Scaffold-DbContext generate entities with comments #19113

Closed
Tracked by #22948
netnr opened this issue Nov 29, 2019 · 19 comments · Fixed by #22937
Closed
Tracked by #22948

Can Scaffold-DbContext generate entities with comments #19113

netnr opened this issue Nov 29, 2019 · 19 comments · Fixed by #22937
Assignees
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. community-contribution customer-reported type-enhancement
Milestone

Comments

@netnr
Copy link

netnr commented Nov 29, 2019

Bring comments and swagger output interface more intuitive

@ErikEJ
Copy link
Contributor

ErikEJ commented Nov 29, 2019

Implemented for SQL Server in 3.0

@ajcvickers
Copy link
Member

@netnr Are you asking for comments from the database to be converted to C# comments on entity types? For example:

/// <summary>
///    This came from the database...
/// </summary>
public class Blog
{
    ...
}

@netnr
Copy link
Author

netnr commented Dec 2, 2019

@ajcvickers Yes

@ajcvickers
Copy link
Member

@netnr This is something that we would support as part of #4038. However, external tools such as those from @ErikEJ and @tonysneed may already support this through their templating mechanisms.

@tonysneed
Copy link

@netnr Here is my scaffolding library: https://github.com/TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars. EF Core Power Tools by @ErikEJ also include my scaffolding library.

@ErikEJ
Copy link
Contributor

ErikEJ commented Apr 18, 2020

@ajcvickers Any particular reason why this could not simply be in the product?
see https://github.com/ErikEJ/EFCorePowerTools/pull/372/files for needed changes.

@ajcvickers
Copy link
Member

@ErikEJ Do you really feel people want this behavior by default? /cc @bricelam @JeremyLikness

@ErikEJ
Copy link
Contributor

ErikEJ commented Apr 20, 2020

Not 100% sure, I am making it the default for now in the daily build, but fail to see why it would be an issue.

FWIW, EF Reverse POCO template has it enabled by default, and I cannot find any complaints about it. https://github.com/sjh37/EntityFramework-Reverse-POCO-Code-First-Generator/blob/master/EntityFramework.Reverse.POCO.Generator/Database%20NorthwindSqlCe40.tt#L84 - but then again I just found out who made it the default: sjh37/EntityFramework-Reverse-POCO-Code-First-Generator#16 😆

I also saw this: sjh37/EntityFramework-Reverse-POCO-Code-First-Generator@41a7eaa

@ajcvickers
Copy link
Member

@ErikEJ Let's circle back round after it's been the default for a month or two. If there are still no complaints, then we should consider it.

@ErikEJ
Copy link
Contributor

ErikEJ commented Apr 20, 2020

@ajcvickers Sounds good, I will do a release to MarketPlace soon then.

@ErikEJ
Copy link
Contributor

ErikEJ commented Sep 11, 2020

@ajcvickers Power Tools with comments on by default has been released since May 2020, and I have not had a single complaint - except about bugs in my implementation 😆

This is what I currently have:

        private void WriteComment(string comment)
        {
            if (!string.IsNullOrWhiteSpace(comment))
            {
                _sb.AppendLine("/// <summary>");

                foreach (var line in comment.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None))
                {
                    _sb.AppendLine($"/// {System.Security.SecurityElement.Escape(line)}");
                }

                _sb.AppendLine("/// </summary>");
            }
        }

@ajcvickers
Copy link
Member

Thanks for the update, @ErikEJ.

@bricelam
Copy link
Contributor

I do this in my T4 templates by default too. Looking at Erik's code, I have a few bugs to fix... 😬

@ErikEJ
Copy link
Contributor

ErikEJ commented Sep 13, 2020

@bricelam yeah, that was also my initial implementation, until I faced some real life comments

@ErikEJ
Copy link
Contributor

ErikEJ commented Oct 8, 2020

Are you planning to enable this in EF Core 6 ? (I could do a PR)

@bricelam
Copy link
Contributor

bricelam commented Oct 8, 2020

I think we'd happily accept a PR for 6.0

ErikEJ pushed a commit to ErikEJ/EntityFramework that referenced this issue Oct 9, 2020
smitpatel pushed a commit that referenced this issue Oct 16, 2020
@smitpatel smitpatel self-assigned this Oct 16, 2020
@smitpatel smitpatel modified the milestones: Backlog, 6.0.0 Oct 16, 2020
@smitpatel smitpatel added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. and removed consider-for-current-release labels Oct 16, 2020
@ajcvickers ajcvickers modified the milestones: 6.0.0, 6.0.0-preview1 Jan 27, 2021
@Gambero81
Copy link

Is this feature only for ef6? can be ported in current ef5?

@roji
Copy link
Member

roji commented Apr 8, 2021

@Gambero81 EF Core 5.0 has already been released, and so is only receiving important bug fixes. See our release planning page for more details.

@ErikEJ
Copy link
Contributor

ErikEJ commented Apr 9, 2021

@Gambero81 it is available in EF core power Tools for EF Core 5

@ajcvickers ajcvickers modified the milestones: 6.0.0-preview1, 6.0.0 Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-scaffolding closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. community-contribution customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants