An open API service indexing awesome lists of open source software.

https://github.com/allencch/monomigrations

MonoMigrations is to provide some migrations feature on Mono based on Entity Framework 6
https://github.com/allencch/monomigrations

Last synced: 4 months ago
JSON representation

MonoMigrations is to provide some migrations feature on Mono based on Entity Framework 6

Awesome Lists containing this project

README

        

# MonoMigrations
MonoMigrations is to provide some migrations feature based on Entity Framework 6.
Entity Framework 6 Migrations work with PowerShell. However, in Linux, PowerShell is not available.

## Requirement
- Mono
- EntityFramework (version 6)
- MySql.Data.Entity.EF6 (depend on your project)

## Usage
Create a console project. Add the MonoMigrations.dll as the reference to the target project.
Then in the source code,

`using MonoMigrations;`

Write the implementation of the migrations, for example

```csharp
internal sealed class MyMigrationConfiguration : DbMigrationsConfiguration {
public MyMigrationConfiguration() {
AutomaticMigrationsEnabled = true; //Have to set to true, due to the limitation
AutomaticMigrationDataLossAllowed = false; //Set to true if allow data loss

//Example using MySQL, this is required if want to use scaffolding (generate the *.cs files)
SetSqlGenerator("MySql.Data.MySqlClient", new MySql.Data.Entity.MySqlMigrationSqlGenerator());
}

protected override void Seed(FooBarContext context) { }
}
```

Then in the Main(),

```csharp
public static void Main (string[] args) {
var config = new MyMigrationConfiguration ();
new MigrationsMain (config, args);
}
```

Build the console application.

Then, to use the created console,

`./myMigration.exe -a yourMigrationName`

This is based on Add-Migration. 3 files will be created in the working directory,

- XXXXXXXXXXXXXXX_yourMigrationName.cs
- XXXXXXXXXXXXXXX_yourMigrationName.Designer.cs
- XXXXXXXXXXXXXXX_yourMigrationName.resx

where the XXX... are the digits.

Then, to update the database,

`./myMigration.exe -u`

This will only work if `AutomaticMigrationsEnabled = true`.

## Limitations
The current stage can only update with automatic migrations. As a result, the database will contain
the migration IDs as XXXXXXXXXXXXXXX_AutomaticMigration, and cannot use the migrations that is
created by "-a" option.

Similarly, the DbMigrator methods GetPendingMigrations() and GetLocalMigrations() do not work,
except GetDatabaseMigrations().

Lastly, I have tried to use Entity Framework SQLite, but failed to work.