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
- Host: GitHub
- URL: https://github.com/allencch/monomigrations
- Owner: allencch
- License: bsd-3-clause
- Created: 2015-09-16T14:01:01.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-09-18T16:16:01.000Z (over 9 years ago)
- Last Synced: 2024-12-30T21:56:13.087Z (5 months ago)
- Language: C#
- Homepage:
- Size: 145 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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.resxwhere 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.