Skip to content

Commit ad426b0

Browse files
authored
Add tutorial in README (#4)
1 parent b046960 commit ad426b0

File tree

5 files changed

+61
-3
lines changed

5 files changed

+61
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.idea
22
bin/
3-
obj/
3+
obj/
4+
.DS_Store

README.md

100644100755
Lines changed: 59 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,59 @@
1-
# efmig
2-
Missing GUI for Entity Framework Core migrations.
1+
# efmig
2+
3+
This is a multi-platform GUI application that greatly speeds up development when using Entity Framework Core.
4+
5+
![alt text](images/main.png)
6+
7+
8+
Why you should use it:
9+
* You'll no longer need to remember `dotnet ef` commands syntax for creating, removing and generating migration scripts.
10+
* Dependency on `Microsoft.EntityFrameworkCore.Design` can be dropped inside your project.
11+
* You can remove `IDesignTimeDbContextFactory<TDbContext>` implementations from your project.
12+
13+
**Important**: This tool **does not** apply migrations on your database. It's designed to be non-destructive and you're expected to generate migration script, review it and run it manually in database client of your choice.
14+
15+
## Configuration
16+
17+
1. Download binaries for your platform from Releases page and launch the `efmig` executable.
18+
2. Click `[+]` button to create a new configuration profile.
19+
3. Fill configuration values
20+
- Profile name: this is a label of your choice for configuration profile.
21+
- dotnet-ef version: See [NuGet page](https://www.nuget.org/packages/dotnet-ef/#versions-body-tab) for available versions. Enter version matching your project.
22+
- Microsoft.EntityFrameworkCore.Design version: See [NuGet page](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Design/#versions-body-tab) for available versions.
23+
- Target framework version: See [this reference table](https://learn.microsoft.com/en-us/dotnet/standard/frameworks#supported-target-frameworks) for available versions.
24+
- DbContext .csproj path: pick the path of C# project that holds your DbContext class.
25+
- DbContext fully qualified name: this is a full class name of DbContext, for example `MyApp.MyDbContext`.
26+
- DbContext configuration code: here you need to configure connection string for `dotnet-ef` to work. See [explanation below](#dbcontext-configuration-code).
27+
4. Save profile.
28+
29+
### DbContext configuration code
30+
31+
`optionsBuilder` variable of type `DbContextBuilder<TYourDbContext>` is defined and you are expected to configure connection string using C# syntax.
32+
33+
Postgres example
34+
```csharp
35+
var connectionString = "Host=myserver;Username=mylogin;Password=mypass;Database=mydatabase";
36+
optionsBuilder.UseNpgsql(connectionString);
37+
```
38+
39+
MySQL example
40+
```csharp
41+
var connectionString = "server=localhost;user=myuser;password=mypassword;database=mydb;";
42+
var serverVersion = ServerVersion.AutoDetect(connectionString);
43+
optionsBuilder.UseMySql(connectionString, serverVersion);
44+
```
45+
46+
## Usage
47+
You can invoke one of the following actions:
48+
- Create a new migration. Specify its name beforehand and click `[+]` button on the right.
49+
- List migrations. This action does nothing but lists already existing migrations.
50+
- Remove most recent migration. This action removes most recent migration from **the code**. Nothing will happen on the actual database.
51+
- Generate migration script. This action opens default text editor with SQL code of all migrations for you to review.
52+
53+
## Other screenshots
54+
55+
#### Profile configuration
56+
![alt text](images/profile-settings.png)
57+
58+
#### Migration script output
59+
![alt text](images/migration-script.png)

images/main.png

932 KB
Loading

images/migration-script.png

340 KB
Loading

images/profile-settings.png

361 KB
Loading

0 commit comments

Comments
 (0)