-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
26 lines (24 loc) · 1015 Bytes
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
using System;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Migrations;
using System.Data.Entity.Migrations.Infrastructure;
using System.Linq;
using System.Reflection;
namespace EFScripter
{
class Program
{
static void Main(string[] args)
{
Database.DefaultConnectionFactory = new SqlConnectionFactory(args[0]);
var assembly = Assembly.LoadFrom(args[1]);
var contextType = assembly.GetExportedTypes().Single(x => typeof (DbContext).IsAssignableFrom(x));
var configuration = (DbMigrationsConfiguration)Activator.CreateInstance(typeof (DbMigrationsConfiguration<>).MakeGenericType(contextType));
configuration.AutomaticMigrationsEnabled = true;
var migrator = new DbMigrator(configuration);
var scripter = new MigratorScriptingDecorator(migrator);
Console.WriteLine(scripter.ScriptUpdate(null, null));
}
}
}