-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
React to DbContextOptions name change
- Loading branch information
1 parent
fdaccc7
commit 04b6f92
Showing
1 changed file
with
54 additions
and
54 deletions.
There are no files selected for viewing
108 changes: 54 additions & 54 deletions
108
...oft.Framework.CodeGeneration.EntityFramework/Templates/DbContext/NewLocalDbContext.cshtml
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 | Diff line number | Diff line change |
---|---|---|
@@ -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;[email protected];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;[email protected];Trusted_Connection=True;MultipleActiveResultSets=true"); | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder builder) | ||
{ | ||
} | ||
} | ||
@{ | ||
if (!String.IsNullOrEmpty(Model.DbContextNamespace)) | ||
{ | ||
//ClearIndent(); | ||
@:} | ||
} | ||
} |