Created
November 15, 2013 22:43
-
-
Save mikecole/7492962 to your computer and use it in GitHub Desktop.
Context T4 template used by Reverse Engineer Code First - After
This file contains hidden or 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
<#@ 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 <#= code.EscapeNamespace(efHost.MappingNamespace) #>; | |
namespace <#= code.EscapeNamespace(efHost.Namespace) #> | |
{ | |
public class <#= efHost.EntityContainer.Name #> : DbContext | |
{ | |
public <#= efHost.EntityContainer.Name #>() | |
: base("HumanResources") | |
{ | |
} | |
<# | |
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()); | |
<# | |
} | |
#> | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment