Skip to content

Commit

Permalink
fixed several issues plaguing schema bound entities, several improvem…
Browse files Browse the repository at this point in the history
…ents made to the model generator
  • Loading branch information
MoonStorm committed Jun 3, 2024
1 parent 69b99f5 commit 677393d
Show file tree
Hide file tree
Showing 10 changed files with 264 additions and 148 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/.vs
/.idea
/packages
bin
obj
Expand Down
152 changes: 98 additions & 54 deletions Dapper.FastCrud.ModelGenerator/Content/Models/GenericModelGenerator.tt

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,31 @@ You can right click on your configuration file and click on "Debug T4 Template"
// An optional suffix to be used for the class names.
ClassSuffix = "Entity";

// The class modifiers to be used for the generated entities.
ClassModifiers = "public partial";

// The property modifiers to be used for the generated entities.
PropertyModifiers = "public virtual";

// For columns that were found to have an invalid name, they can be prefixed.
InvalidPropertyNamePrefix = "Prop";

// If true, views will also get processed.
IncludeViews = true;
IncludeViews = true;

// If true, schemas will be generated as part of the metadata for the entities.
IncludeSchemas = true;

// If true, the relationships will be analyzed and navigation properties created.
IncludeRelationships = true;
IncludeRelationships = true;

// When set to false, the generated properties mapped to columns having default values will be refreshed with the database assigned values on insert.
// When set to false, a FastCrud attribute will be used since this functionality is not covered by the regular component model data annotations.
// When set to false, a FastCrud attribute will be used since this functionality is not covered by the regular component model data annotations.
IgnoreColumnDefaultValues = true;

// Table or schema qualified table and view names can be excluded via this property.
ExcludeTablePrefixes = new string[]{"ELMAH", "AspNet_", "HangFire."};
ExcludeTablePrefixes = new string[]{"ELMAH", "AspNet_", "HangFire.", "access."};

#>
<#@ include file="$(DapperFastCrudModelGeneratorPath)GenericModelGenerator.tt" #>
<#+
Expand Down
18 changes: 15 additions & 3 deletions Dapper.FastCrud.ModelGenerator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Head over to the wiki section on the project website for more details.
[Key]
[Column(Order = 1)]
[ForeignKey(nameof(Employee))]
public virtual int Id { get; set; }
public virtual int AssetId { get; set; }
/// <summary>
/// Represents the column 'EmployeeId'.
Expand All @@ -38,12 +38,24 @@ Head over to the wiki section on the project website for more details.
/// <summary>
/// Represents the navigation property for the child-parent relationship involving <seealso cref="EmployeeEntity"/>
/// </summary>
public virtual EmployeeEntity Employee { get; set; }
public virtual EmployeeEntity? Employee { get; set; }
}
```

## Release Notes for 3.0
## Release Notes

### 3.3
- An opt-in flag was added for generating schema decorated entities.
- Several problems involving schemas were fixed
(e.g. identical table names in separate schemas, relationships, general metadata extraction).
- Parent entity properties are now generated as nullable.
- Added support for ``TimeOnly`` and ``DateOnly``.
- Added warning suppressions for non-nullable properties.
- Customizable entity class modifiers.
- Customizable entity property modifiers.

### 3.0
- [Breaking change] Support for composite primary keys.
- [Breaking change] Added support for self referenced entities.
- [Breaking change] Added support for multiple references to the same target using the InverseProperty attribute.
Expand Down
Binary file modified Dapper.FastCrud.Tests/App_Data/EntityGenDatabase.mdf
Binary file not shown.
Binary file modified Dapper.FastCrud.Tests/App_Data/EntityGenDatabase_log.ldf
Binary file not shown.
Loading

0 comments on commit 677393d

Please sign in to comment.