EasyAbp / AbpHelper.CLI

Providing code generation and more features to help you develop applications and modules with the ABP framework.
MIT License
285 stars 95 forks source link

CRUD generator: generate property configurations #123

Closed gdlcf88 closed 3 years ago

gdlcf88 commented 3 years ago

Should generate property configurations when the command generate crud runs.

builder.Entity<Product>(b =>
{
    b.ToTable(MyAppConsts.DbTablePrefix + "Product", MyAppConsts.DbSchema);

    b.ConfigureByConvention(); 

    /* Configure more properties here */

    b.Property(x => x.Name);   // auto generated
    b.Property(x => x.Description);   // auto generated
    b.Property(x => x.Price).HasColumnType("decimal(18, 2)");   // auto generated, 
});
wakuflair commented 3 years ago

The first two lines are unnecessary, do they have special use?

The last line "HasColumnType` is not likely to be auto generated.

gdlcf88 commented 3 years ago

Just like the ABP official modules did, maybe configuring Fluent API is a good practice.

decimal(18, 2) is EF Core's default column type for a decimal property, if we did not set the HasColumnType for decimal properties manually, we will get a warning when using the ef-tools.

wakuflair commented 3 years ago

decimal(18, 2) is EF Core's default column type for a decimal property

So why do we need to manually configure it?

gdlcf88 commented 3 years ago

decimal(18, 2) prevents the warning and make the column type clearer.

However, I am not really sure if we need to create Fluent API configurations like ABP's modules did. 😄

wakuflair commented 3 years ago

Close for now. Reopen later if needed.