yavsc/build/approot/packages/Microsoft.Extensions.CodeGe.../1.0.0-rc1-final/Templates/DbContext/NewLocalDbContext.cshtml

53 lines
1.3 KiB
Plaintext

@inherits Microsoft.Extensions.CodeGeneration.Templating.RazorTemplateBase
using Microsoft.Data.Entity;
@{
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)
{
_created = true;
Database.EnsureCreated();
}
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
}
public DbSet<@Model.ModelTypeName> @Model.ModelTypeName { get; set; }
}
@{
if (!String.IsNullOrEmpty(Model.DbContextNamespace))
{
//ClearIndent();
@:}
}
}