Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
{{#if model-namespace}}
using {{model-namespace}};
{{/if}}
{{#each model-imports}}
using {{model-import}};
{{/each}}
{{/each}}
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using EFCorePowerToolsExample.Data;
using System;
using System.Collections.Generic;
{{#if use-data-annotations}}
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using Microsoft.EntityFrameworkCore;
{{/if}}
{{#each imports}}
using {{import}};
{{/each}}
{{/each}}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
{{#if property-comment}}

/// <summary>
{{property-comment}}
{{property-comment}}
/// </summary>
{{/if}}
{{#each property-annotations}}
{{{property-annotation}}}
{{/each}}
public {{property-type}} {{property-name}} { get; set; }{{#if nullable-reference-types }}{{#unless property-isnullable}} = null!;{{/unless}}{{/if}}
public {{property-type}} {{property-name}} { get; set; }{{#if nullable-reference-types }}{{#unless property-isnullable}} = null!;{{/unless}}{{else}}{{#if property-default-enum}} = {{property-default-enum}};{{/if}}{{/if}}
{{/each}}
{{#if nav-properties}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<#@ import namespace="Microsoft.EntityFrameworkCore.Scaffolding" #>
<#@ import namespace="Microsoft.Extensions.DependencyInjection" #>
<#
// Template version: 703 - please do NOT remove this line
if (!ProductInfo.GetVersion().StartsWith("7.0"))
// Template version: 1000 - please do NOT remove this line
if (!ProductInfo.GetVersion().StartsWith("10.0"))
{
Warning("Your templates were created using an older version of Entity Framework. Additional features and bug fixes may be available. See https://aka.ms/efcore-docs-updating-templates for more information.");
}
Expand All @@ -28,6 +28,8 @@

var usings = new List<string>
{
"System",
"System.Collections.Generic",
"Microsoft.EntityFrameworkCore"
};

Expand Down Expand Up @@ -80,11 +82,14 @@ public partial class <#= Options.ContextName #> : DbContext
if (!Options.SuppressConnectionStringWarning)
{
#>
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see https://go.microsoft.com/fwlink/?LinkId=723263.
<#
}

var useProviderCall = providerCode.GenerateUseProvider(Options.ConnectionString);
usings.AddRange(useProviderCall.GetRequiredUsings());
#>
=> optionsBuilder<#= code.Fragment(providerCode.GenerateUseProvider(Options.ConnectionString), indent: 3) #>;
=> optionsBuilder<#= code.Fragment(useProviderCall, indent: 3) #>;

<#
}
Expand Down Expand Up @@ -337,6 +342,13 @@ public partial class <#= Options.ContextName #> : DbContext
<#
mainEnvironment = GenerationEnvironment;
GenerationEnvironment = new StringBuilder();

WriteLine("// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>");
if (Options.UseNullableReferenceTypes)
{
WriteLine("#nullable enable");
}
WriteLine("");

foreach (var ns in usings.Distinct().OrderBy(x => x, new NamespaceComparer()))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<#@ import namespace="Microsoft.EntityFrameworkCore.Design" #>
<#@ import namespace="Microsoft.Extensions.DependencyInjection" #>
<#
// Template version: 703 - please do NOT remove this line
// Template version: 1000 - please do NOT remove this line
if (EntityType.IsSimpleManyToManyJoinEntityType())
{
// Don't scaffold these
Expand All @@ -27,6 +27,8 @@

var usings = new List<string>
{
"System",
"System.Collections.Generic"
};

if (Options.UseDataAnnotations)
Expand Down Expand Up @@ -158,6 +160,13 @@ public partial class <#= EntityType.Name #>
<#
var previousOutput = GenerationEnvironment;
GenerationEnvironment = new StringBuilder();

WriteLine("// <auto-generated> This file has been auto generated by EF Core Power Tools. </auto-generated>");
if (Options.UseNullableReferenceTypes)
{
WriteLine("#nullable enable");
}
WriteLine("");

foreach (var ns in usings.Distinct().OrderBy(x => x, new NamespaceComparer()))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EfCore.SchemaCompare" Version="7.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="10.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.13">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="10.0.13" />
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="10.0.13" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ BEGIN

RETURN @Count;
END;
GO

CREATE PROCEDURE CountBooksInCategory_SP
(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
CREATE DATABASE DatabaseFirstDevelopmentUsingEFCorePowerToolsDB
GO

USE DatabaseFirstDevelopmentUsingEFCorePowerToolsDB

CREATE TABLE Authors (
Expand Down Expand Up @@ -26,8 +29,10 @@ CREATE TABLE Books_Categories (
FOREIGN KEY (BookID) REFERENCES Books(ID),
FOREIGN KEY (CategoryID) REFERENCES Categories(ID)
);
GO

CREATE SCHEMA dbo2
CREATE SCHEMA dbo2;
GO

CREATE TABLE dbo2.Movies (
ID INT IDENTITY(1,1) PRIMARY KEY,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
USE DatabaseFirstDevelopmentUsingEFCorePowerToolsDB
GO

CREATE VIEW BookDetails AS
SELECT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"CodeGenerationMode": 3,
"CodeGenerationMode": 6,
"ContextClassName": "DBContext",
"ContextNamespace": "Data",
"DefaultDacpacSchema": null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"CodeGenerationMode": 3,
"CodeGenerationMode": 6,
"ContextClassName": "DBO2Context",
"ContextNamespace": "Data",
"DefaultDacpacSchema": null,
Expand Down
Loading