Exemple #1
0
            public SimpleProject()
            {
                var source = new BuildSource
                {
                    TargetDir  = TargetDir,
                    References =
                    {
                        BuildReference.ByName("System.Diagnostics.DiagnosticSource",                   true),
                        BuildReference.ByName("System.Interactive.Async",                              true),
                        BuildReference.ByName("System.Data.SqlClient",                                 true),
                        BuildReference.ByName("Microsoft.EntityFrameworkCore",                         true),
                        BuildReference.ByName("Microsoft.EntityFrameworkCore.Design",                  true),
                        BuildReference.ByName("Microsoft.EntityFrameworkCore.Relational",              true),
                        BuildReference.ByName("Microsoft.EntityFrameworkCore.SqlServer",               true),
                        BuildReference.ByName("Microsoft.Extensions.Caching.Abstractions",             true),
                        BuildReference.ByName("Microsoft.Extensions.Caching.Memory",                   true),
                        BuildReference.ByName("Microsoft.Extensions.Configuration.Abstractions",       true),
                        BuildReference.ByName("Microsoft.Extensions.DependencyInjection",              true),
                        BuildReference.ByName("Microsoft.Extensions.DependencyInjection.Abstractions", true),
                        BuildReference.ByName("Microsoft.Extensions.Logging",                          true),
                        BuildReference.ByName("Microsoft.Extensions.Logging.Abstractions",             true),
                        BuildReference.ByName("Microsoft.Extensions.Options",                          true),
                        BuildReference.ByName("Microsoft.Extensions.Primitives",                       true),
                        BuildReference.ByName("Remotion.Linq",                                         true)
                    },
                    Sources =
                    {
                        @"
                            using Microsoft.EntityFrameworkCore;
                            using Microsoft.EntityFrameworkCore.Infrastructure;
                            using Microsoft.EntityFrameworkCore.Migrations;

                            namespace SimpleProject
                            {
                                internal class SimpleContext : DbContext
                                {
                                    protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
                                    {
                                        optionsBuilder.UseSqlServer(""Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=SimpleProject.SimpleContext;Integrated Security=True"");
                                    }
                                }

                                namespace Migrations
                                {
                                    [DbContext(typeof(SimpleContext))]
                                    [Migration(""20141010222726_InitialCreate"")]
                                    public class InitialCreate : Migration
                                    {
                                        protected override void Up(MigrationBuilder migrationBuilder)
                                        {
                                        }
                                    }
                                }
                            }"
                    }
                };
                var build = source.Build();

                File.Copy(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile, build.TargetPath + ".config");
                Executor = new AppDomainOperationExecutor(
                    build.TargetPath,
                    build.TargetPath,
                    build.TargetDir,
                    build.TargetDir,
                    "SimpleProject");
            }