public virtual IEnumerable<string> ReverseEngineer(
            [NotNull] string providerAssemblyName,
            [NotNull] string connectionString,
            [NotNull] string rootNamespace,
            [NotNull] string projectDir)
        {
            Check.NotNull(providerAssemblyName, nameof(providerAssemblyName));
            Check.NotEmpty(connectionString, nameof(connectionString));
            Check.NotEmpty(rootNamespace, nameof(rootNamespace));
            Check.NotEmpty(projectDir, nameof(projectDir));

            var assembly = Assembly.Load(new AssemblyName(providerAssemblyName));
            if (assembly == null)
            {
                throw new InvalidOperationException(Strings.CannotFindAssembly(providerAssemblyName));
            }

            var configuration = new ReverseEngineeringConfiguration()
            {
                ProviderAssembly = assembly,
                ConnectionString = connectionString,
                Namespace = rootNamespace,
                OutputPath = projectDir
            };

            var generator = new ReverseEngineeringGenerator(_serviceProvider);
            return generator.GenerateAsync(configuration).Result;
        }
        public EntityTypeCodeGenerator(
            [NotNull] ReverseEngineeringGenerator generator,
            [NotNull] IEntityType entityType,
            [NotNull] string namespaceName)
        {
            Check.NotNull(generator, nameof(generator));
            Check.NotNull(entityType, nameof(entityType));
            Check.NotEmpty(namespaceName, nameof(namespaceName));

            Generator      = generator;
            EntityType     = entityType;
            ClassNamespace = namespaceName;
        }
Beispiel #3
0
        public DbContextCodeGenerator(
            [NotNull] ReverseEngineeringGenerator generator,
            [NotNull] IModel model, [NotNull] string namespaceName,
            [CanBeNull] string className, [NotNull] string connectionString)
        {
            Check.NotNull(generator, nameof(generator));
            Check.NotNull(model, nameof(model));
            Check.NotEmpty(namespaceName, nameof(namespaceName));
            Check.NotEmpty(connectionString, nameof(connectionString));

            Generator        = generator;
            Model            = model;
            ClassNamespace   = namespaceName;
            ClassName        = className;
            ConnectionString = connectionString;
        }
Beispiel #4
0
 public void Constructs_correct_namespace(
     string rootNamespace, string projectPath, string outputPath, string resultingNamespace)
 {
     Assert.Equal(resultingNamespace,
                  ReverseEngineeringGenerator.ConstructNamespace(rootNamespace, projectPath, outputPath));
 }