Closed JohnGoldInc closed 4 years ago
@tonysneed Any feedback?
@johngold-onshift The way I think we want to approach adding support for nullable reference types is to add an EnableNullableReferenceTypes
property to ReverseEngineerOptions
so that you can set it to true in ConfigureDesignTimeServices
when calling services.AddHandlebarsScaffolding
.
public void ConfigureDesignTimeServices(IServiceCollection services)
{
services.AddHandlebarsScaffolding(options =>
{
options.EnableNullableReferenceTypes = true;
});
}
Then in HbsCSharpEntityTypeGenerator.GenerateProperties
check property.IsNullable
to add a '?' to properties that are nullable in the database.
Metadata will need to be added, so that the Properties.hbs template can be modified to set defaults for non-nullable properties and generate output that uses the null forgiving operator.
public partial class Customer
{
public string CompanyName { get; set; } = default!;
}
Would you be able to create a new PR that takes this approach?
For schema foldering support, would you create another issue and a separate PR? Thanks!
@JohnGoldInc Do you plan to open another PR to implement the approach I suggested?
Yes, just got distracted today :)
Get Outlook for iOShttps://aka.ms/o0ukef
From: Anthony Sneed notifications@github.com Sent: Tuesday, April 28, 2020 5:46:06 PM To: TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars EntityFrameworkCore.Scaffolding.Handlebars@noreply.github.com Cc: John Gold jgold@onshift.com; Mention mention@noreply.github.com Subject: Re: [TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars] Changes to Support Schema Foldering, And Nullable EF Core Project (#99)
@JohnGoldInchttps://github.com/JohnGoldInc Do you plan to open another PR to implement the approach I suggested?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/TrackableEntities/EntityFrameworkCore.Scaffolding.Handlebars/pull/99#issuecomment-620872338, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOO3LNUNMZ2I7Z6MJJHQYGLRO5FB5ANCNFSM4KPK5BHA.
@JohnGoldInc Be sure to create a new branch from the latest commit on my master branch (5b2d3d24). Use this branch for your new PR.
For some guidance on creating the PR, please refer to the Contributing Guidelines.
@tonysneed For EnableNullableReferenceTypes ; do you want me to check in changes to sample project ? (where I am testing it)
Yes I think that is a good idea to check in changes to the sample project. That way, I can also run it on my side to see if I get the same behavior.
@tonysneed I deleted CodeTemplates folder to let it regenerate; I see it would want to remove things like: // Comment // My Handlebars Block Helper {{my-helper}}
I assume you would want me to put that back?
Oh yes, don't delete the templates. Better if you could just update them.
Changes to Support Schema Foldering, And Nullable EF Core Project Using propertyTransformer: (epi) => new EntityFrameworkCore.Scaffolding.Handlebars.EntityPropertyInfo(epi.PropertyType + (epi.PropertyIsNullable == true && !epi.PropertyType.Contains("?") ? "?" :"") , epi.PropertyName, epi.PropertyIsNullable)