diff --git a/src/Microsoft.Framework.CodeGeneration.EntityFramework/Templates/DbContext/NewLocalDbContext.cshtml b/src/Microsoft.Framework.CodeGeneration.EntityFramework/Templates/DbContext/NewLocalDbContext.cshtml index e3cda92ea..ff7094cde 100644 --- a/src/Microsoft.Framework.CodeGeneration.EntityFramework/Templates/DbContext/NewLocalDbContext.cshtml +++ b/src/Microsoft.Framework.CodeGeneration.EntityFramework/Templates/DbContext/NewLocalDbContext.cshtml @@ -1,55 +1,55 @@ -@inherits Microsoft.Framework.CodeGeneration.Templating.RazorTemplateBase -using Microsoft.Data.Entity; -using Microsoft.Data.Entity.Metadata; -@{ - foreach (var namespaceName in Model.RequiredNamespaces) - { -@:using @namespaceName; - } -@: - string baseClassName; - if (String.Equals(Model.DbContextTypeName, "DbContext", StringComparison.Ordinal)) - { - baseClassName = "Microsoft.Data.Entity.DbContext"; - } - else - { - baseClassName = "DbContext"; - } - if (!String.IsNullOrEmpty(Model.DbContextNamespace)) - { -@:namespace @Model.DbContextNamespace -@:{ - //PushIndent(" "); - } -} public class @Model.DbContextTypeName : @baseClassName - { - private static bool _created = false; - - public @(Model.DbContextTypeName)() - { - if (!_created) - { - Database.EnsureCreated(); - _created = true; - } - } - - public DbSet<@Model.ModelTypeName> @Model.ModelTypeName { get; set; } - - protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) - { - optionsBuilder.UseSqlServer(@@"Server=(localdb)\mssqllocaldb;Database=@Model.DbContextTypeName;Trusted_Connection=True;MultipleActiveResultSets=true"); - } - - protected override void OnModelCreating(ModelBuilder builder) - { - } - } -@{ - if (!String.IsNullOrEmpty(Model.DbContextNamespace)) - { - //ClearIndent(); -@:} - } +@inherits Microsoft.Framework.CodeGeneration.Templating.RazorTemplateBase +using Microsoft.Data.Entity; +using Microsoft.Data.Entity.Metadata; +@{ + foreach (var namespaceName in Model.RequiredNamespaces) + { +@:using @namespaceName; + } +@: + string baseClassName; + if (String.Equals(Model.DbContextTypeName, "DbContext", StringComparison.Ordinal)) + { + baseClassName = "Microsoft.Data.Entity.DbContext"; + } + else + { + baseClassName = "DbContext"; + } + if (!String.IsNullOrEmpty(Model.DbContextNamespace)) + { +@:namespace @Model.DbContextNamespace +@:{ + //PushIndent(" "); + } +} public class @Model.DbContextTypeName : @baseClassName + { + private static bool _created = false; + + public @(Model.DbContextTypeName)() + { + if (!_created) + { + Database.EnsureCreated(); + _created = true; + } + } + + public DbSet<@Model.ModelTypeName> @Model.ModelTypeName { get; set; } + + protected override void OnConfiguring(EntityOptionsBuilder optionsBuilder) + { + optionsBuilder.UseSqlServer(@@"Server=(localdb)\mssqllocaldb;Database=@Model.DbContextTypeName;Trusted_Connection=True;MultipleActiveResultSets=true"); + } + + protected override void OnModelCreating(ModelBuilder builder) + { + } + } +@{ + if (!String.IsNullOrEmpty(Model.DbContextNamespace)) + { + //ClearIndent(); +@:} + } } \ No newline at end of file