-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathContext.tt
35 lines (30 loc) · 943 Bytes
/
Context.tt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<#@ 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;
namespace <#= code.EscapeNamespace(efHost.Namespace) #>
{
public partial 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; }
<#
}
#>
}
}