| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- <#@ 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 CommonTool;
- using <#= code.EscapeNamespace(efHost.MappingNamespace) #>;
- 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(new GetConnStr().ConnStr)
- {
- }
- <#
- 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());
- <#
- }
- #>
- }
- }
- }
|