Skip to content

Commit

Permalink
Auto install dotnet ef
Browse files Browse the repository at this point in the history
  • Loading branch information
davidfowl committed Jan 11, 2025
1 parent a519c10 commit beb0011
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ It showcases:

### Database

1. Install the **dotnet-ef** tool: `dotnet tool install dotnet-ef -g`
1. Learn more about [dotnet-ef](https://learn.microsoft.com/en-us/ef/core/cli/dotnet)
The application uses SQLite and entity framework. .NET Aspire is used to bootstrap all dependencies.

### Running the application

Expand Down
6 changes: 5 additions & 1 deletion TodoApp.AppHost/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ public static IResourceBuilder<ExecutableResource> AddEfMigration<TProject>(this
{
var projectDirectory = Path.GetDirectoryName(new TProject().ProjectPath)!;

// Install the EF tool
var install = builder.AddExecutable("install-ef", "dotnet", projectDirectory, "tool", "install", "--global", "dotnet-ef");

// TODO: Support passing a connection string
return builder.AddExecutable(name, "dotnet", projectDirectory, "ef", "database", "update", "--no-build");
return builder.AddExecutable(name, "dotnet", projectDirectory, "ef", "database", "update", "--no-build")
.WaitForCompletion(install);
}

public static string GetProjectDirectory(this IResourceBuilder<ProjectResource> project) =>
Expand Down

0 comments on commit beb0011

Please sign in to comment.