Skip to content

Commit be82103

Browse files
committed
Remove use of UseDataAnnotationsSchema, and simply rely on UseDataAnnotations flag
1 parent 266526c commit be82103

File tree

7 files changed

+8
-24
lines changed

7 files changed

+8
-24
lines changed

EntityFramework.Reverse.POCO.Generator/Database NorthwindSqlCe40.tt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
Settings.UseMappingTables = true; // If true, mapping will be used and no mapping tables will be generated. If false, all tables will be generated.
2929
Settings.UsePascalCase = true; // This will rename the generated C# tables & properties to use PascalCase. If false table & property names will be left alone.
3030
Settings.UseDataAnnotations = false; // If true, will add data annotations to the poco classes.
31-
Settings.UseDataAnnotationsSchema = false; // UseDataAnnotations must also be true. If true, will add data annotations schema to the poco classes.
3231
Settings.UsePropertyInitializers = false; // Removes POCO constructor and instead uses C# 6 property initialisers to set defaults
3332
Settings.UseLazyLoading = true; // Marks all navigation properties as virtual or not, to support or disable EF Lazy Loading feature
3433
Settings.IncludeComments = CommentsStyle.AtEndOfField; // Adds comments to the generated code
@@ -468,8 +467,6 @@
468467

469468

470469
// Read schema
471-
if (!Settings.UseDataAnnotations)
472-
Settings.UseDataAnnotationsSchema = false;
473470
var factory = GetDbProviderFactory();
474471
Settings.Tables = LoadTables(factory);
475472
Settings.StoredProcs = LoadStoredProcs(factory);

EntityFramework.Reverse.POCO.Generator/Database.tt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
Settings.UseMappingTables = true; // If true, mapping will be used and no mapping tables will be generated. If false, all tables will be generated.
2929
Settings.UsePascalCase = true; // This will rename the generated C# tables & properties to use PascalCase. If false table & property names will be left alone.
3030
Settings.UseDataAnnotations = false; // If true, will add data annotations to the poco classes.
31-
Settings.UseDataAnnotationsSchema = false; // UseDataAnnotations must also be true. If true, will add data annotations schema to the poco classes.
3231
Settings.UsePropertyInitializers = false; // Removes POCO constructor and instead uses C# 6 property initialisers to set defaults
3332
Settings.UseLazyLoading = true; // Marks all navigation properties as virtual or not, to support or disable EF Lazy Loading feature
3433
Settings.IncludeComments = CommentsStyle.AtEndOfField; // Adds comments to the generated code
@@ -522,8 +521,6 @@
522521

523522

524523
// Read schema
525-
if (!Settings.UseDataAnnotations)
526-
Settings.UseDataAnnotationsSchema = false;
527524
var factory = GetDbProviderFactory();
528525
Settings.Tables = LoadTables(factory);
529526
Settings.StoredProcs = LoadStoredProcs(factory);

EntityFramework.Reverse.POCO.Generator/EF.Reverse.POCO.Core.ttinclude

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
public static string CollectionType = "System.Collections.Generic.List";
7979
public static bool NullableShortHand;
8080
public static bool UseDataAnnotations;
81-
public static bool UseDataAnnotationsSchema;
8281
public static bool MakeClassesPartial;
8382
public static bool MakeClassesInternal;
8483
public static bool MakeDbContextInterfacePartial;
@@ -631,7 +630,7 @@
631630

632631
foreach (var t in tables)
633632
{
634-
if(Settings.UseDataAnnotationsSchema)
633+
if(Settings.UseDataAnnotations)
635634
t.SetupDataAnnotations();
636635
t.Suffix = Settings.TableSuffix;
637636
}
@@ -927,34 +926,34 @@
927926

928927
if (IsIdentity || isNewSequentialId)
929928
{
930-
if(Settings.UseDataAnnotationsSchema || isNewSequentialId)
929+
if(Settings.UseDataAnnotations || isNewSequentialId)
931930
DataAnnotations.Add("DatabaseGenerated(DatabaseGeneratedOption.Identity)");
932931
else
933932
databaseGeneratedOption = string.Format(".HasDatabaseGeneratedOption({0}DatabaseGeneratedOption.Identity)", schemaReference);
934933
}
935934
else if(IsComputed())
936935
{
937-
if(Settings.UseDataAnnotationsSchema)
936+
if(Settings.UseDataAnnotations)
938937
DataAnnotations.Add("DatabaseGenerated(DatabaseGeneratedOption.Computed)");
939938
else
940939
databaseGeneratedOption = string.Format(".HasDatabaseGeneratedOption({0}DatabaseGeneratedOption.Computed)", schemaReference);
941940
}
942941
else if (IsPrimaryKey)
943942
{
944-
if(Settings.UseDataAnnotationsSchema)
943+
if(Settings.UseDataAnnotations)
945944
DataAnnotations.Add("DatabaseGenerated(DatabaseGeneratedOption.None)");
946945
else
947946
databaseGeneratedOption = string.Format(".HasDatabaseGeneratedOption({0}DatabaseGeneratedOption.None)", schemaReference);
948947
}
949948

950949
var sb = new StringBuilder();
951950

952-
if(Settings.UseDataAnnotationsSchema || (IsPrimaryKey && Settings.UseDataAnnotations))
951+
if(Settings.UseDataAnnotations)
953952
DataAnnotations.Add(string.Format("Column(@\"{0}\", Order = {1}, TypeName = \"{2}\")", Name, Ordinal, SqlPropertyType));
954953
else
955954
sb.AppendFormat(".HasColumnName(@\"{0}\").HasColumnType(\"{1}\")", Name, SqlPropertyType);
956955

957-
if (Settings.UseDataAnnotationsSchema && Indexes.Any())
956+
if (Settings.UseDataAnnotations && Indexes.Any())
958957
{
959958
foreach (var index in Indexes)
960959
{
@@ -2913,7 +2912,7 @@ SELECT SERVERPROPERTY('Edition') AS Edition,
29132912
string fkPropName = pkTable.GetUniqueColumnName(fkTable.NameHumanCase, foreignKey, checkForFkNameClashes, fkMakePropNameSingular, Relationship.OneToMany);
29142913

29152914
var dataAnnotation = string.Empty;
2916-
if (Settings.UseDataAnnotations && Settings.UseDataAnnotationsSchema)
2915+
if (Settings.UseDataAnnotations)
29172916
{
29182917
dataAnnotation = string.Format("[ForeignKey(\"{0}\"){1}] ",
29192918
string.Join(", ", fkCols.Select(x => x.col.NameHumanCase).Distinct().ToArray()),

EntityFramework.Reverse.POCO.Generator/EF.Reverse.POCO.ttinclude

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1101,7 +1101,7 @@ if(Settings.IncludeComments != CommentsStyle.None){#> // <#=tbl.Name#>
11011101

11021102
public <#=tbl.NameHumanCaseWithSuffix() + Settings.ConfigurationClassName#>(string schema)
11031103
{
1104-
<#if(!Settings.UseDataAnnotationsSchema){ if (!string.IsNullOrEmpty(tbl.Schema)) { #>
1104+
<#if(!Settings.UseDataAnnotations){ if (!string.IsNullOrEmpty(tbl.Schema)) { #>
11051105
ToTable("<#=tbl.Name#>", schema);
11061106
<# } else { #>
11071107
ToTable("<#=tbl.Name#>");

Tester/TestDatabase_DataAnnotation.tt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
Settings.UseMappingTables = true; // If true, mapping will be used and no mapping tables will be generated. If false, all tables will be generated.
2929
Settings.UsePascalCase = true; // This will rename the generated C# tables & properties to use PascalCase. If false table & property names will be left alone.
3030
Settings.UseDataAnnotations = true; // If true, will add data annotations to the poco classes.
31-
Settings.UseDataAnnotationsSchema = true; // UseDataAnnotations must also be true. If true, will add data annotations schema to the poco classes.
3231
Settings.UsePropertyInitializers = false; // Removes POCO constructor and instead uses C# 6 property initialisers to set defaults
3332
Settings.UseLazyLoading = true; // Marks all navigation properties as virtual or not, to support or disable EF Lazy Loading feature
3433
Settings.IncludeComments = CommentsStyle.AtEndOfField; // Adds comments to the generated code
@@ -516,8 +515,6 @@
516515

517516

518517
// Read schema
519-
if (!Settings.UseDataAnnotations)
520-
Settings.UseDataAnnotationsSchema = false;
521518
var factory = GetDbProviderFactory();
522519
Settings.Tables = LoadTables(factory);
523520
Settings.StoredProcs = LoadStoredProcs(factory);

Tester/TestDatabase_NoDataAnnotation.tt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
Settings.UseMappingTables = true; // If true, mapping will be used and no mapping tables will be generated. If false, all tables will be generated.
2929
Settings.UsePascalCase = true; // This will rename the generated C# tables & properties to use PascalCase. If false table & property names will be left alone.
3030
Settings.UseDataAnnotations = false; // If true, will add data annotations to the poco classes.
31-
Settings.UseDataAnnotationsSchema = false; // UseDataAnnotations must also be true. If true, will add data annotations schema to the poco classes.
3231
Settings.UsePropertyInitializers = false; // Removes POCO constructor and instead uses C# 6 property initialisers to set defaults
3332
Settings.UseLazyLoading = true; // Marks all navigation properties as virtual or not, to support or disable EF Lazy Loading feature
3433
Settings.IncludeComments = CommentsStyle.AtEndOfField; // Adds comments to the generated code
@@ -516,8 +515,6 @@
516515

517516

518517
// Read schema
519-
if (!Settings.UseDataAnnotations)
520-
Settings.UseDataAnnotationsSchema = false;
521518
var factory = GetDbProviderFactory();
522519
Settings.Tables = LoadTables(factory);
523520
Settings.StoredProcs = LoadStoredProcs(factory);

Tester/TestSynonymsDatabase.tt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
Settings.UseMappingTables = true; // If true, mapping will be used and no mapping tables will be generated. If false, all tables will be generated.
2929
Settings.UsePascalCase = true; // This will rename the generated C# tables & properties to use PascalCase. If false table & property names will be left alone.
3030
Settings.UseDataAnnotations = false; // If true, will add data annotations to the poco classes.
31-
Settings.UseDataAnnotationsSchema = false; // UseDataAnnotations must also be true. If true, will add data annotations schema to the poco classes.
3231
Settings.UsePropertyInitializers = false; // Removes POCO constructor and instead uses C# 6 property initialisers to set defaults
3332
Settings.UseLazyLoading = true; // Marks all navigation properties as virtual or not, to support or disable EF Lazy Loading feature
3433
Settings.IncludeComments = CommentsStyle.AtEndOfField; // Adds comments to the generated code
@@ -516,8 +515,6 @@
516515

517516

518517
// Read schema
519-
if (!Settings.UseDataAnnotations)
520-
Settings.UseDataAnnotationsSchema = false;
521518
var factory = GetDbProviderFactory();
522519
Settings.Tables = LoadTables(factory);
523520
Settings.StoredProcs = LoadStoredProcs(factory);

0 commit comments

Comments
 (0)