I use the flag --use-database-names when generating my classes, table names are done fine, but field names are still PascalCaseify.
Regards!
@piyey - EF Core does not generate fields. Are you referring to Properties generated inside Entitytypes?
I mean field names of my tables are PascalCaseify when generating POCO classes.
Can you post example of one of incorrectly generated POCO classes?
I'm not on my dev machine, so I will try to explain it on the fly (sorry).
My table:
this_is_my_table
-field_one INT
-field_two INT
-field_three INT
Generated POCO classes:
public class this_is_my_table
{
public int FieldOne {get;set;}
public int FieldTwo {get;set;}
public int FieldThree {get;set;}
}
If you see, table name is not PascalCaseify in the class name, but field names do in properties.
Presently Column Naming does not switch based on UseDatabaseNames (like DbSet & EntityType naming does).
@piyey in C# public int Property {get; set;} is auto-property whereas public int Field; is field (no getter/setter for a field). Therefore it was bit confusing.
Another interesting observation. We have convention to use DbSet name as table name. Shouldn't reveng scaffold dbset name same as table name regardless of naming strategy.
Do you mean UseDatabaseNames apply only to table name but not to columns names?
@smitpatel sorry for Field word, I meant column (in spanish we call fields to the columns of a table)
Do you mean UseDatabaseNames apply only to table name but not to columns names?
Yes. At least in current code base. We will discuss in team meeting if that is expected behavior or column naming was left out in hindsight.
Same issues, additional details:
Column Names are still changed, see EQID below:
```C#
modelBuilder.Entity
{
entity.HasKey(e => new { e.Eqid, e.Analyte });
entity.Property(e => e.Eqid)
.HasColumnName("EQID")
.HasMaxLength(20);
```
...
Command used:
dotnet ef dbcontext scaffold "Server=SLCOHW3DSILIO1;Database=sunrise_demo_data;Trusted_Connection=True;" "Microsoft.EntityFrameworkCore.SqlServer" -o "Models" -f -t "DCUTRANSLATIONS" --use-database-names
CLI
--use-database-names Use table and column names directly from the database.
Same Issue.
field names are still PascalCaseify
Working with it is impossible.
I need a fix quickly.
@BlackBackground Hope this helps, it helped me: use EF vs core if you have the option, it works (table and column names preserved as is) when reverse engineering model:
https://msdn.microsoft.com/en-us/library/jj200620(v=vs.113).aspx, see step 3.
@siliond Thanks your your answer. Unfortunately your answer doesn't help. The structure must be updated frequently.
@BlackBackground Indeed, I don't know how to regenerate again easily besides deleting the model and classes and adding it again.
Does the team consider pull requests for fixing something like this?
@camelinckx Absolutely. Please let us know if you're working on it.
@ajcvickers I am, testing now, pushing a PR shortly.
Most helpful comment
Same Issue.
field names are still PascalCaseify
Working with it is impossible.
I need a fix quickly.