This repository has been archived by the owner on Nov 29, 2017. It is now read-only.
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
60 changed files
with
4,912 additions
and
0 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
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,31 @@ | |||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 | |||
# Visual Studio 11 | |||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{2AE1B177-580C-44F1-9514-B3F23F4B1433}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerTools", "src\PowerTools\PowerTools.csproj", "{16CAD3A8-FCE0-4BC1-901A-16957CF24BD6}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PowerTools.Test", "test\PowerTools.Test\PowerTools.Test.csproj", "{ADCD3A3D-2564-48F3-81A9-B0B532675808}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
Debug|Any CPU = Debug|Any CPU | |||
Release|Any CPU = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||
{16CAD3A8-FCE0-4BC1-901A-16957CF24BD6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{16CAD3A8-FCE0-4BC1-901A-16957CF24BD6}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{16CAD3A8-FCE0-4BC1-901A-16957CF24BD6}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{16CAD3A8-FCE0-4BC1-901A-16957CF24BD6}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{ADCD3A3D-2564-48F3-81A9-B0B532675808}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{ADCD3A3D-2564-48F3-81A9-B0B532675808}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{ADCD3A3D-2564-48F3-81A9-B0B532675808}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{ADCD3A3D-2564-48F3-81A9-B0B532675808}.Release|Any CPU.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
EndGlobalSection | |||
GlobalSection(NestedProjects) = preSolution | |||
{ADCD3A3D-2564-48F3-81A9-B0B532675808} = {2AE1B177-580C-44F1-9514-B3F23F4B1433} | |||
EndGlobalSection | |||
EndGlobal |
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
src/PowerTools/CodeTemplates/ReverseEngineerCodeFirst/Context.tt
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,47 @@ | |||
<#@ template hostspecific="true" language="C#" #> | |||
<#@ include file="EF.Utility.CS.ttinclude" #><#@ | |||
output extension=".cs" #><# | |||
|
|||
var efHost = (EfTextTemplateHost)Host; | |||
var code = new CodeGenerationTools(this); | |||
#> | |||
using System.Data.Entity; | |||
using System.Data.Entity.Infrastructure; | |||
using <#= code.EscapeNamespace(efHost.MappingNamespace) #>; | |||
|
|||
namespace <#= code.EscapeNamespace(efHost.Namespace) #> | |||
{ | |||
public class <#= efHost.EntityContainer.Name #> : DbContext | |||
{ | |||
static <#= efHost.EntityContainer.Name #>() | |||
{ | |||
Database.SetInitializer<<#= efHost.EntityContainer.Name #>>(null); | |||
} | |||
|
|||
public <#= efHost.EntityContainer.Name #>() | |||
: base("Name=<#= efHost.EntityContainer.Name #>") | |||
{ | |||
} | |||
|
|||
<# | |||
foreach (var set in efHost.EntityContainer.BaseEntitySets.OfType<EntitySet>()) | |||
{ | |||
#> | |||
public DbSet<<#= set.ElementType.Name #>> <#= set.Name #> { get; set; } | |||
<# | |||
} | |||
#> | |||
|
|||
protected override void OnModelCreating(DbModelBuilder modelBuilder) | |||
{ | |||
<# | |||
foreach (var set in efHost.EntityContainer.BaseEntitySets.OfType<EntitySet>()) | |||
{ | |||
#> | |||
modelBuilder.Configurations.Add(new <#= set.ElementType.Name #>Map()); | |||
<# | |||
} | |||
#> | |||
} | |||
} | |||
} |
63 changes: 63 additions & 0 deletions
63
src/PowerTools/CodeTemplates/ReverseEngineerCodeFirst/Entity.tt
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,63 @@ | |||
<#@ template hostspecific="true" language="C#" #> | |||
<#@ include file="EF.Utility.CS.ttinclude" #><#@ | |||
output extension=".cs" #><# | |||
|
|||
var efHost = (EfTextTemplateHost)Host; | |||
var code = new CodeGenerationTools(this); | |||
#> | |||
using System; | |||
using System.Collections.Generic; | |||
|
|||
namespace <#= code.EscapeNamespace(efHost.Namespace) #> | |||
{ | |||
public class <#= efHost.EntityType.Name #> | |||
{ | |||
<# | |||
var collectionNavigations = efHost.EntityType.NavigationProperties.Where( | |||
np => np.DeclaringType == efHost.EntityType | |||
&& np.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many); | |||
|
|||
// Add a ctor to initialize any collections | |||
if (collectionNavigations.Any()) | |||
{ | |||
#> | |||
public <#= code.Escape(efHost.EntityType) #>() | |||
{ | |||
<# | |||
foreach (var navProperty in collectionNavigations) | |||
{ | |||
#> | |||
this.<#= code.Escape(navProperty) #> = new List<<#= code.Escape(navProperty.ToEndMember.GetEntityType()) #>>(); | |||
<# | |||
} | |||
#> | |||
} | |||
|
|||
<# | |||
} | |||
|
|||
foreach (var property in efHost.EntityType.Properties) | |||
{ | |||
#> | |||
<#= Accessibility.ForProperty(property) #> <#= code.Escape(property.TypeUsage) #> <#= code.Escape(property) #> { get; set; } | |||
<# | |||
} | |||
|
|||
foreach (var navProperty in efHost.EntityType.NavigationProperties.Where(np => np.DeclaringType == efHost.EntityType)) | |||
{ | |||
if (navProperty.ToEndMember.RelationshipMultiplicity == RelationshipMultiplicity.Many) | |||
{ | |||
#> | |||
public virtual ICollection<<#= code.Escape(navProperty.ToEndMember.GetEntityType()) #>> <#= code.Escape(navProperty) #> { get; set; } | |||
<# | |||
} | |||
else | |||
{ | |||
#> | |||
public virtual <#= code.Escape(navProperty.ToEndMember.GetEntityType()) #> <#= code.Escape(navProperty) #> { get; set; } | |||
<# | |||
} | |||
} | |||
#> | |||
} | |||
} |
Oops, something went wrong.