-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
54 changed files
with
2,190 additions
and
768 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
PoweredSoft.DbUtils.EF.Generator.EF6.Core/IEF6GeneratorOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using PoweredSoft.DbUtils.EF.Generator.Core; | ||
|
||
namespace PoweredSoft.DbUtils.EF.Generator.EF6.Core | ||
{ | ||
public interface IEF6GeneratorOptions : IGeneratorOptions | ||
{ | ||
string ConnectionStringName { get; set; } | ||
string FluentConfigurationClassSuffix { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer/DatabaseGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using PoweredSoft.CodeGenerator; | ||
using PoweredSoft.DbUtils.EF.Generator.Core; | ||
using PoweredSoft.DbUtils.EF.Generator.SqlServer; | ||
using PoweredSoft.DbUtils.Schema.Core; | ||
using PoweredSoft.DbUtils.Schema.SqlServer; | ||
|
||
namespace PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer | ||
{ | ||
public class DatabaseGenerator : EF6DatabaseGeneratorBase<IDatabaseSchema, GeneratorOptions> | ||
{ | ||
protected override IDataTypeResolver DataTypeResolver { get; } = new DataTypeResolver(); | ||
public override IDatabaseSchema CreateSchema() => new DatabaseSchema(); | ||
public override IGeneratorOptions GetDefaultOptions() => new GeneratorOptions(); | ||
|
||
public override void InitializeOptionsWithDefault() | ||
{ | ||
Options = GetDefaultOptions() as GeneratorOptions;; | ||
} | ||
|
||
protected override void GenerateGetNextSequenceLines(MethodBuilder method, string outputType, ISequence sequence) | ||
{ | ||
var sqlServerSequence = (Sequence)sequence; | ||
method.RawLine($"return Database.SqlQuery<{outputType}>(\"SELECT NEXT VALUE FOR [{sqlServerSequence.Schema}].[{sequence.Name}];\").First()"); | ||
} | ||
|
||
protected override string EmptyMetas(string text) => base.EmptyMetas(text).EmptyMetas(); | ||
protected override string ReplaceMetas(string text, ITable table) => base.ReplaceMetas(text, table).ReplaceMetas((Table)table); | ||
public override List<ITable> ResolveTablesToGenerate() => base.ResolveTablesToGenerate().ShouldGenerate(Options); | ||
public override List<ISequence> ResolveSequencesToGenerate() => base.ResolveSequencesToGenerate().ShouldGenerate(Options); | ||
|
||
protected override bool IsGenerateOptionIdentity(IColumn column) | ||
{ | ||
if (column.DefaultValue?.IndexOf("newsequentialid", StringComparison.InvariantCultureIgnoreCase) > -1) | ||
return true; | ||
|
||
return base.IsGenerateOptionIdentity(column); | ||
} | ||
|
||
protected override string ToTableFluent(ITable table) | ||
{ | ||
var sqlServerTable = (Table)table; | ||
return $"ToTable(\"{table.Name}\", \"{sqlServerTable.Schema}\")"; | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer/GeneratorOptions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using PoweredSoft.DbUtils.EF.Generator.EF6.Core; | ||
using PoweredSoft.DbUtils.EF.Generator.SqlServer.Core; | ||
|
||
namespace PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer | ||
{ | ||
public class GeneratorOptions : IEF6GeneratorOptions, ISqlServerGeneratorOptions | ||
{ | ||
public List<string> ExcludedTables { get; set; } = new List<string>() | ||
{ | ||
"dbo.sysdiagrams" | ||
}; | ||
|
||
public List<string> IncludedTables { get; set; } = new List<string>(); | ||
public string Namespace { get; set; } | ||
public string ContextName { get; set; } | ||
public string ContextBaseClassName { get; set; } = "System.Data.Entity.DbContext"; | ||
public string ConnectionString { get; set; } | ||
public string OutputDir { get; set; } | ||
public bool CleanOutputDir { get; set; } = false; | ||
public bool OutputToSingleFile => !string.IsNullOrWhiteSpace(OutputSingleFileName); | ||
public bool GenerateContextSequenceMethods { get; set; } | ||
public string OutputSingleFileName { get; set; } | ||
public bool GenerateInterfaces { get; set; } = false; | ||
public string InterfaceNameSuffix { get; set; } = ""; | ||
public bool GenerateModels { get; set; } = false; | ||
public bool GenerateModelsInterfaces { get; set; } = false; | ||
public bool GenerateModelPropertyAsNullable { get; set; } = false; | ||
public string ModelSuffix { get; set; } = "Base"; | ||
public string ModelInterfaceSuffix { get; set; } = ""; | ||
public List<string> ModelInheritances { get; set; } = new List<string>(); | ||
public string Version => "6"; | ||
public string Engine => "SqlServer"; | ||
public string ConnectionStringName { get; set; } | ||
public string FluentConfigurationClassSuffix { get; set; } = "FluentConfiguration"; | ||
public List<string> IncludedSchemas { get; } = new List<string>(); | ||
public List<string> ExcludedSchemas { get; } = new List<string>(); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
....DbUtils.EF.Generator.EF6.SqlServer/PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<Version>1.0.3</Version> | ||
<Copyright>Powered Softwares Inc.</Copyright> | ||
<PackageLicenseUrl>https://github.com/PoweredSoft/DbUtils/blob/master/LICENSE.md</PackageLicenseUrl> | ||
<PackageProjectUrl>https://github.com/PoweredSoft/DbUtils</PackageProjectUrl> | ||
<RepositoryUrl>https://github.com/PoweredSoft/DbUtils/PoweredSoft.DbUtils.EF.Generator.EF6.SqlServer</RepositoryUrl> | ||
<RepositoryType>github</RepositoryType> | ||
<PackageIconUrl></PackageIconUrl> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\PoweredSoft.DbUtils.EF.Generator.EF6.Core\PoweredSoft.DbUtils.EF.Generator.EF6.Core.csproj" /> | ||
<ProjectReference Include="..\PoweredSoft.DbUtils.EF.Generator.EF6\PoweredSoft.DbUtils.EF.Generator.EF6.csproj" /> | ||
<ProjectReference Include="..\PoweredSoft.DbUtils.EF.Generator.SqlServer\PoweredSoft.DbUtils.EF.Generator.SqlServer.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.