Skip to content

Commit

Permalink
React to DbContextOptions name change
Browse files Browse the repository at this point in the history
  • Loading branch information
ajcvickers committed May 26, 2015
1 parent fdaccc7 commit 04b6f92
Showing 1 changed file with 54 additions and 54 deletions.
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();
@:}
}
}

0 comments on commit 04b6f92

Please sign in to comment.