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

Add Microsoft.EntityFrameworkCore.Templates #28678

Merged
1 commit merged into from
Aug 11, 2022
Merged

Add Microsoft.EntityFrameworkCore.Templates #28678

1 commit merged into from
Aug 11, 2022

Conversation

bricelam
Copy link
Contributor

Adds a new package that can be installed via dotnet new:

dotnet new install Microsoft.EntityFrameworkCore.Templates::7.0.0-*

For now, it just includes a single item template that will add the default T4 templates used by dotnet ef dbcontext scaffold.

dotnet new ef-templates

You can then tweak the templates and they'll automatically be used when scaffolding.

dotnet ef dbcontext scaffold Filename=northwind.db Microsoft.EntityFrameworkCore.Sqlite

Resolves #4038

Adds a new package that can be installed via `dotnet new`:

    dotnet new install Microsoft.EntityFrameworkCore.Templates::7.0.0-*

For now, it just includes a single item template that will add the default T4 templates used by `dotnet ef dbcontext scaffold`.

    dotnet new ef-templates

You can then tweak the templates and they'll automatically be used when scaffolding.

    dotnet ef dbcontext scaffold Filename=northwind.db Microsoft.EntityFrameworkCore.Sqlite

Resolves dotnet#4038
@bricelam bricelam requested a review from a team August 11, 2022 19:01
@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 11, 2022

Looking forward - will this be in rc1?

</ParameterGroup>
<Task>
<Using Namespace="System.IO" />
<Code Type="Fragment" Language="cs">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about inlining the task source here, we should discuss

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I considered a lot of alternatives. This one seemed the most maintainable.

@bricelam
Copy link
Contributor Author

@ErikEJ Yep! We're branching for it sometime next week. lol, that's why there's been a flurry of PRs from the team...

@ghost
Copy link

ghost commented Aug 11, 2022

Hello @bricelam!

Because this pull request has the auto-merge label, I will be glad to assist with helping to merge this pull request once all check-in policies pass.

p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (@msftbot) and give me an instruction to get started! Learn more here.

@ghost
Copy link

ghost commented Aug 11, 2022

Apologies, while this PR appears ready to be merged, I've been configured to only merge when all checks have explicitly passed. The following integrations have not reported any progress on their checks and are blocking auto-merge:

  1. Azure Pipelines

These integrations are possibly never going to report a check, and unblocking auto-merge likely requires a human being to update my configuration to exempt these integrations from requiring a passing check.

Give feedback on this
From the bot dev team

We've tried to tune the bot such that it posts a comment like this only when auto-merge is blocked for exceptional, non-intuitive reasons. When the bot's auto-merge capability is properly configured, auto-merge should operate as you would intuitively expect and you should not see any spurious comments.

Please reach out to us at fabricbotservices@microsoft.com to provide feedback if you believe you're seeing this comment appear spuriously. Please note that we usually are unable to update your bot configuration on your team's behalf, but we're happy to help you identify your bot admin.

@ghost ghost merged commit 7a9756c into dotnet:main Aug 11, 2022
@bricelam bricelam deleted the new branch August 12, 2022 00:45
@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 12, 2022

@bricelam yes. I have noticed the rush hour.

@andre-artus
Copy link

Is this feature available to use? I have .NET 7.0.100-preview.7.22377.5 installed along with the 7.0.0-preview.7.22376.2 versions of M.EFC.SqlServer and M.EFC.Tools but when I try to install the templates using the method described above I get the following:

> dotnet new install Microsoft.EntityFrameworkCore.Templates::7.0.0-*
The following template packages will be installed:
   Microsoft.EntityFrameworkCore.Templates::7.0.0-*

dotnet : Microsoft.EntityFrameworkCore.Templates::7.0.0-* could not be installed, the package does not exist.
At line:1 char:1
+ dotnet new install Microsoft.EntityFrameworkCore.Templates::7.0.0-*
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Microsoft.Entit...does not exist.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError
 

For details on the exit code, refer to https://aka.ms/templating-exit-codes#103

Is there something I'm missing?

@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 30, 2022

@andre-artus It is in the daily builds, and coming in RC1 around second week of september.

Or you can try it today in EF Core Power Tools latest daily.

@andre-artus
Copy link

Thanks Erik. I can wait for the RC1. This is a great addition for me as I am working on a DB that uses [unnecessary] prefixes and suffixes all over that just end up muddying the generated code..

Is there much of a difference between what is produced by EF scaffolding and EFC PT?

@ajcvickers
Copy link
Member

@andre-artus Highly recommend you use the daily builds. RC1 is already behind by some way, and will be massively behind by the time it releases.

@ErikEJ
Copy link
Contributor

ErikEJ commented Aug 30, 2022

@andre-artus not much difference as PT uses same scaffolding Framework. But you can Fix bad object names today with EF Core Power Tools- no need to wait for templates.

@bricelam
Copy link
Contributor Author

Opened PR #28920 to add instructions for installing daily builds of the template pack

@andre-artus
Copy link

Thanks Erik and Brice. I'll try the dailies.

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code templates for scaffolding entity types and DbContext from an existing database
6 participants