we use database first and want to switch from t4 to autoquery/ autocrud for generation of model classes.
Our database has around 500 different tables using inconsistent naming conventions regarding tablenames and column names. We already use the t4 generated models a lot in our code base.
How can we change the generation of the table data model classes so that they are not converted to c# naming conventions? The table model classes should just use the names that we use in our ms sql server database for table names and columns.
Your preferred TableName and C# class name should be configured there. The ctx.TableName controls which RDBMS Name is used (using OrmLite’s [Alias]) whilst the ctx.DataModelName controls the C# class name to use.
This now almost generates the code in the same way as the T4 template. It misses the [Reference] attribute, though. Do you know if I can somehow get this? I know I can add them to the Attribute collection. But I didn’t find the foreign key information in any of the objects that are available in the TypeFilter. (Perhaps I just missed them.)
You’d need to explicitly add the [Reference] attributes and properties you want. I recommend Exporting the Code-First DTOs and remove the runtime code generation so you can take over maintenance of the Data Models to apply your preferred customizations.