dotnet / dotnet/EntityFramework.Docs

Documentation for `EFMigrations` msbuild target

Open
#2,829 2 comments 0 reactions 0 assignees View on GitHub
area-migrations
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

## Ask a question

I've been scouring the web trying to figure out how to get our migration script to be generated automatically as part of `dotnet publish`. Lots of old articles regarding including a migrate.exe... ick

I enabled diagnostic output on a dotnet-publish invocation and lo-and-behold, there's already an EFMigrations task!!!

But I can't seem to find any documentation for how to configure it, or how to ensure the file is included in the publish directory.

We're using dotnet core and publishing on macs and ubuntu (GitHub Actions), so the (very few) posts I've seen regarding configuring a pub.xml don't seem to apply (VS4mac doesn't seem to support customized publish profiles?)

Regardless, what I'm looking for is hopefully some documentation around how to use this task in our msbuild configuration such that it runs during publish, and is included in the final /publish directory.

I'd also be grateful if anyone just linked to the source of Task Class itself that backs this msbuild target...

So far, I've just blindly stumbled my way to adding:

```

```

to our .csproj file. And that has gotten us to:

```
_GenerateEFSQLScripts:
Generating Entity framework SQL Scripts...
Executing command: dotnet ef migrations script --idempotent --output "/Users/jasonkarns//obj/Release/netcoreapp3.1/win-x64/PubTmp/EFSQLScripts/FisContext.sql" --context FisContext
Generating Entity framework SQL Scripts completed successfully
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.