-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathcli-help.txt
More file actions
2125 lines (1942 loc) · 120 KB
/
Copy pathcli-help.txt
File metadata and controls
2125 lines (1942 loc) · 120 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
dotnet linq2db - Linq To DB command-line utilities. Version: 6.0.0.0
Usage:
dotnet linq2db scaffold <options>
Options:
=== General : basic options
-i, --import : path to JSON file with scaffold options
type: string (optional)
json: not allowed
When both command line and JSON file contains same option, value from command line will override value from file for single-value options and will combine values for multi-value opti
ons.
JSON property type depends on option type: bool for boolean properties, integer number for numeric properties and string for other properties.
If property could have multiple values, it should use array as property type.
JSON file example:
{
"general": {
"output": "c:\my\project\datamodel",
"overwrite": true,
"provider": "SQLServer",
},
"code": {
"nrt": false
}
}
-o, --output : relative or full path to folder to put generated files
type: string (optional)
json: general.output
If folder doesn't exists, it will be created. When not specified, current folder used.
-f, --overwrite : overwrite existing files
type: bool (optional)
json: general.overwrite
default: false
default (T4 mode): false
-p, --provider : database provider (database)
type: string (required)
json: general.provider
supported values:
Access : MS Access (requires OLE DB or/and ODBC provider installed)
DB2 : IBM DB2 LUW or z/OS
Firebird : Firebird
Informix : IBM Informix
SQLServer : MS SQL Server (including Azure SQL Server)
MySQL : MySQL/MariaDB
Oracle : Oracle Database
PostgreSQL : PostgreSQL
SqlCe : MS SQL Server Compact
SQLite : SQLite
Sybase : SAP/Sybase ASE
SapHana : SAP HANA
ClickHouseMySql : ClickHouse (MySql interface)
ClickHouseHttp : ClickHouse (HTTP(S) interface)
ClickHouseTcp : ClickHouse (TCP/binary interface)
-l, --provider-location : database provider location
type: string (optional)
json: general.provider-location
Allows user to specify path to database provider for some databases.
Supported databases:
- SQL Server Compact Edition : value is a full path to System.Data.SqlServerCe.dll assembly from Private folder of SQL CE installation
- SAP HANA : value is a full path to Sap.Data.Hana.Core.v2.1.dll, Sap.Data.Hana.Net.v6.0.dll or Sap.Data.Hana.Net.v8.0.dll assembly from HDB client installation fol
der
- IBM DB2 and Informix : value is a full path to IBM.Data.DB2.Core.dll assembly in DB2 provider folder
-c, --connection : database connection string
type: string (required)
json: general.connection
--additional-connection : secondary database connection string
type: string (optional)
json: general.additional-connection
Allows user to specify additional database connection using different provider. This option supported only for Access and require that main and additional connection strings use OLE
DB and ODBC (in any order).
This is caused by fact that both OLE DB and ODBC Access providers return incomplete or invalid information in different places. Using database schema data from both providers allows
us to build complete and proper database schema.
List of known issues, solved this way:
- OLE DB doesn't provide information about autoincrement (counter) columns
- OLE DB returns nullable type for procedure column returned for table counter column
- ODBC doesn't provide information about primary keys and foreign keys
- ODBC marks all columns in tables and procedure results as nullable except counter and bit
- ODBC doesn't provide length information for text-based procedure parameter type
- ODBC doesn't show some procedures in schema (no logic traced)
-a, --architecture : process architecture for utility
type: string (optional)
json: general.architecture
supported values:
x86 : x86 architecture
x64 : x64 architecture
By default utility runs AnyCPU build, which could result in error in multi-arch environment when platform-specific database provider used and provider's architecture doesn't match pr
ocess architecture. For such provider you could specify process architecture explicitly.
Example of platform-specific providers:
- OLE DB providers
- ODBC providers
- thin wrappers over native provider (e.g. IBM.Data.DB2 providers)
-t, --template : select base set of default options
type: string (optional)
json: general.template
default: default
default (T4 mode): default
supported values:
default : set of parameters, used by default (as specified in option help)
t4 : set of parameters, similar to T4 defaults (compat. option)
Specify this option only if you want to to use scaffolding options, similar to used by old T4 templates by default
--customize : specify path to T4 template or assembly with scaffolding customization logic
type: string (optional)
json: general.customize
Option accepts path to file with customization logic which could be:
- assembly (recognized by .dll extension);
- T4 template.
If you choose T4, you can create initial empty template using 'dotnet linq2db template' command. It will generate initial template file with pre-generated extension points which you
can modify to implement required customizations.
Customization using compiled assembly has several requirements:
- it should be compatible with current runtime, used by 'dotnet linq2db' tool;
- assembly should contain exactly one interceptor class with customization logic. It should be inherited from ScaffoldInterceptors and has default public constructor;
- linq2db.Scaffold version should match tool's version to avoid possible compatibility issues/errors.
=== Database Schema : database schema load
--objects : schema objects to load
type: string list (optional)
json: schema.objects
default: table, view, foreign-key
default (T4 mode): table, view, foreign-key, stored-procedure, scalar-function, table-function, aggregate-function
supported values:
table : load tables
view : load views
foreign-key : load foreign key constrains
stored-procedure : load stored procedures
scalar-function : load scalar functions
table-function : load table functions
aggregate-function : load aggregate/window functions
examples:
--objects table,stored-procedure,table-function
JSON examples:
{ "schema": { "objects": ["table", "view", "table-function"] } }
--prefer-provider-types : prefer provider-specific data types to regular .net types for columns and parameters
type: bool (optional)
json: schema.prefer-provider-types
default: false
default (T4 mode): false
Database provider could have db-specific .net types to better mapping handling to database types. E.g. MySqlGeometry, NpgsqlInet or OracleTimeStampLTZ types, provided by correspondin
g providers.
--ignore-duplicate-fk : load only first (or order, returned by database) foreign key with same columns
type: bool (optional)
json: schema.ignore-duplicate-fk
default: true
default (T4 mode): false
--safe-schema-only : load stored procedure/table function schema using only safe methods
type: bool (optional)
json: schema.safe-schema-only
default: true
default (T4 mode): false
Don't use CommandBehavior.SchemaOnly execution mode to load stored procedure or table function schema as it is not safe if them contain non-transactional code.
--database-in-name : include database name in name of db object in database schema
type: bool (optional)
json: schema.database-in-name
default: false
default (T4 mode): false
--load-sproc-schema : enable loading stored procedure schema
type: bool (optional)
json: schema.load-sproc-schema
default: false
default (T4 mode): true
When not set, procedures and their parameters will be loaded, but not result-set schema.
--mssql-enable-return-value-parameter : (only for SQL Server) enable generation of RETURN_VALUE parameter for stored procedures
type: bool (optional)
json: schema.mssql-enable-return-value-parameter
default: false
default (T4 mode): false
--include-schemas : load only specified database schemas
type: string list (optional)
cannot use with: --exclude-schemas
json: schema.include-schemas
--exclude-schemas : do not load specified database schemas
type: string list (optional)
cannot use with: --include-schemas
json: schema.exclude-schemas
--include-catalogs : load only specified database schemas
type: string list (optional)
cannot use with: --exclude-catalogs
json: schema.include-catalogs
--exclude-catalogs : do not load specified database schemas
type: string list (optional)
cannot use with: --include-catalogs
json: schema.exclude-catalogs
--default-schemas : specify which schemas should be recognized as default schemas
type: string list (optional)
json: schema.default-schemas
Objects from schemas, marked as default, will be:
- put to main data context instead of separate schema-specific class (see also schema-as-type option)
- will skip generation of schema name in metadata (see also include-default-schema-name option)
When this option is not set, CLI tool use database-specific logic to detect default schema. Usually it is current user/schema name associated with connection string, used for databas
e scaffolding and supports only one schema. Using this option you can specify multiple schemas.
--include-tables : only load tables with specified name(s)
type: (string | object) list (optional)
cannot use with: --exclude-tables
json: schema.include-tables
examples:
--include-tables Users,Roles,Permissions
JSON examples:
{ "schema": { "include-tables": [ "Users", { "name": "Roles", "schema": "dbo" } ] } } // Users and dbo.Roles tables
{ "schema": { "include-tables": [ { "regex": "^audit_.+$", "schema": "dbo" } ] } } // all tables starting from audit_ prefix
Provided table names should have same casing as actual table name in database. Specifying this option in command line has several limitations and it is recommended to use JSON for it
instead:
- there is no way to specify schema name for table;
- table name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- table schema (schema property);
- regular expression (regex property) instead of exact table name (name property).
JSON list element schema:
{
"name" : string // table name
"schema": string? // table schema (optional)
}
|
{
"regex" : string // table name matching regular expression
"schema": string? // table schema (optional)
}
|
string // also you can put table name as string directly to list
--exclude-tables : skip load of tables with specified name(s)
type: (string | object) list (optional)
cannot use with: --include-tables
json: schema.exclude-tables
examples:
--exclude-tables Users,Roles,Permissions
JSON examples:
{ "schema": { "exclude-tables": [ "Users", { "name": "Roles", "schema": "dbo" } ] } } // Users and dbo.Roles tables ignored
{ "schema": { "exclude-tables": [ { "regex": "^audit_.+$", "schema": "dbo" } ] } } // all tables starting from audit_ prefix ignored
Provided table names should have same casing as actual table name in database. Specifying this option in command line has several limitations and it is recommended to use JSON for it
instead:
- there is no way to specify schema name for table;
- table name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- table schema (schema property);
- regular expression (regex property) instead of exact table name (name property).
JSON list element schema:
{
"name" : string // table name
"schema": string? // table schema (optional)
}
|
{
"regex" : string // table name matching regular expression
"schema": string? // table schema (optional)
}
|
string // also you can put table name as string directly to list
--include-views : only load views with specified name(s)
type: (string | object) list (optional)
cannot use with: --exclude-views
json: schema.include-views
examples:
--include-views Users,Roles,Permissions
JSON examples:
{ "schema": { "include-views": [ "Users", { "name": "Roles", "schema": "dbo" } ] } } // Users and dbo.Roles views
{ "schema": { "include-views": [ { "regex": "^audit_.+$", "schema": "dbo" } ] } } // all views starting from audit_ prefix
Provided view names should have same casing as actual view name in database. Specifying this option in command line has several limitations and it is recommended to use JSON for it i
nstead:
- there is no way to specify schema name for view;
- view name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- view schema (schema property);
- regular expression (regex property) instead of exact view name (name property).
JSON list element schema:
{
"name" : string // view name
"schema": string? // view schema (optional)
}
|
{
"regex" : string // view name matching regular expression
"schema": string? // view schema (optional)
}
|
string // also you can put view name as string directly to list
--exclude-views : skip load of views with specified name(s)
type: (string | object) list (optional)
cannot use with: --include-views
json: schema.exclude-views
examples:
--exclude-views Users,Roles,Permissions
JSON examples:
{ "schema": { "exclude-views": [ "Users", { "name": "Roles", "schema": "dbo" } ] } } // Users and dbo.Roles views ignored
{ "schema": { "exclude-views": [ { "regex": "^audit_.+$", "schema": "dbo" } ] } } // all views starting from audit_ prefix ignored
Provided view names should have same casing as actual view name in database. Specifying this option in command line has several limitations and it is recommended to use JSON for it i
nstead:
- there is no way to specify schema name for view;
- view name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- view schema (schema property);
- regular expression (regex property) instead of exact view name (name property).
JSON list element schema:
{
"name" : string // view name
"schema": string? // view schema (optional)
}
|
{
"regex" : string // view name matching regular expression
"schema": string? // view schema (optional)
}
|
string // also you can put view name as string directly to list
--procedures-with-schema : only load schema for stored procedures with specified name(s)
type: (string | object) list (optional)
cannot use with: --procedures-without-schema
json: schema.procedures-with-schema
examples:
--procedures-with-schema GetUsers,GetRoles,LoadPermissions
JSON examples:
{ "schema": { "procedures-with-schema": [ "GetUsers", { "name": "LoadPermissions", "schema": "dbo" } ] } } // GetUsers and dbo.LoadPermissions procedures
{ "schema": { "procedures-with-schema": [ { "regex": "^Load.+$", "schema": "dbo" } ] } } // all procedures starting from Load prefix
Provided stored procedure names should have same casing as actual procedure name in database. Specifying this option in command line has several limitations and it is recommended to
use JSON for it instead:
- there is no way to specify schema name for procedure;
- procedure name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- procedure schema (schema property);
- regular expression (regex property) instead of exact procedure name (name property).
JSON list element schema:
{
"name" : string // stored procedure name
"schema": string? // stored procedure schema (optional)
}
|
{
"regex" : string // stored procedure name matching regular expression
"schema": string? // stored procedure schema (optional)
}
|
string // also you can put procedure name as string directly to list
--procedures-without-schema : skip load of schema for stored procedures with specified name(s)
type: (string | object) list (optional)
cannot use with: --procedures-with-schema
json: schema.procedures-without-schema
examples:
--procedures-without-schema FormatAllDrives,DropAllTables
JSON examples:
{ "schema": { "procedures-without-schema": [ "DropAllTables", { "name": "FormatAllDrives", "schema": "dbo" } ] } } // DropAllTables and dbo.FormatAllDrives procedures schema not loaded
{ "schema": { "procedures-without-schema": [ { "regex": "^Delete.+$", "schema": "dbo" } ] } } // all procedures starting from Delete prefix
Provided stored procedure names should have same casing as actual procedure name in database. Specifying this option in command line has several limitations and it is recommended to
use JSON for it instead:
- there is no way to specify schema name for procedure;
- procedure name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- procedure schema (schema property);
- regular expression (regex property) instead of exact procedure name (name property).
JSON list element schema:
{
"name" : string // stored procedure name
"schema": string? // stored procedure schema (optional)
}
|
{
"regex" : string // stored procedure name matching regular expression
"schema": string? // stored procedure schema (optional)
}
|
string // also you can put procedure name as string directly to list
--include-stored-procedures : only load stored procedures with specified name(s)
type: (string | object) list (optional)
cannot use with: --exclude-stored-procedures
json: schema.include-stored-procedures
examples:
--include-stored-procedures GetUsers,GetRoles,LoadPermissions
JSON examples:
{ "schema": { "include-stored-procedures": [ "ActiveUsers", { "name": "InactiveUsers", "schema": "dbo" } ] } } // ActiveUsers and dbo.InactiveUsers procedures
{ "schema": { "include-stored-procedures": [ { "regex": "^Query.+$", "schema": "dbo" } ] } } // all stored procedures starting from Query prefix
Provided stored procedures names should have same casing as actual procedure name in database. Specifying this option in command line has several limitations and it is recommended to
use JSON for it instead:
- there is no way to specify schema name for stored procedure;
- stored procedure name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- stored procedure schema (schema property);
- regular expression (regex property) instead of exact stored procedure name (name property).
JSON list element schema:
{
"name" : string // stored procedure name
"schema": string? // stored procedure schema (optional)
}
|
{
"regex" : string // stored procedure name matching regular expression
"schema": string? // stored procedure schema (optional)
}
|
string // also you can put stored procedure name as string directly to list
--exclude-stored-procedures : skip load of stored procedures with specified name(s)
type: (string | object) list (optional)
cannot use with: --include-stored-procedures
json: schema.exclude-stored-procedures
examples:
--exclude-stored-procedure GetUsers,GetRoles,LoadPermissions
JSON examples:
{ "schema": { "exclude-stored-procedure": [ "TestProcedure", { "name": "CheckDb", "schema": "dbo" } ] } } // TestProcedure and dbo.CheckDb procedures ignored
{ "schema": { "exclude-stored-procedure": [ { "regex": "^Audit.+$", "schema": "dbo" } ] } } // all stored procedures starting from Audit prefix ignored
Provided stored procedures names should have same casing as actual procedure name in database. Specifying this option in command line has several limitations and it is recommended to
use JSON for it instead:
- there is no way to specify schema name for stored procedure;
- stored procedure name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- stored procedure schema (schema property);
- regular expression (regex property) instead of exact stored procedure name (name property).
JSON list element schema:
{
"name" : string // stored procedure name
"schema": string? // stored procedure schema (optional)
}
|
{
"regex" : string // stored procedure name matching regular expression
"schema": string? // stored procedure schema (optional)
}
|
string // also you can put stored procedure name as string directly to list
--include-table-functions : only load table functions with specified name(s)
type: (string | object) list (optional)
cannot use with: --exclude-table-functions
json: schema.include-table-functions
examples:
--include-table-functions GetUsers,GetRoles,LoadPermissions
JSON examples:
{ "schema": { "include-table-functions": [ "ActiveUsers", { "name": "InactiveUsers", "schema": "dbo" } ] } } // ActiveUsers and dbo.InactiveUsers functions
{ "schema": { "include-table-functions": [ { "regex": "^Query.+$", "schema": "dbo" } ] } } // all table functions starting from Query prefix
Provided table functions names should have same casing as actual function name in database. Specifying this option in command line has several limitations and it is recommended to us
e JSON for it instead:
- there is no way to specify schema name for table function;
- table function name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- table function schema (schema property);
- regular expression (regex property) instead of exact table function name (name property).
JSON list element schema:
{
"name" : string // table function name
"schema": string? // table function schema (optional)
}
|
{
"regex" : string // table function name matching regular expression
"schema": string? // table function schema (optional)
}
|
string // also you can put table function name as string directly to list
--exclude-table-functions : skip load of table functions with specified name(s)
type: (string | object) list (optional)
cannot use with: --include-table-functions
json: schema.exclude-table-functions
examples:
--exclude-table-functions GetUsers,GetRoles,LoadPermissions
JSON examples:
{ "schema": { "exclude-table-functions": [ "TestFunction", { "name": "CheckDb", "schema": "dbo" } ] } } // TestFunction and dbo.CheckDb functions ignored
{ "schema": { "exclude-table-functions": [ { "regex": "^Audit.+$", "schema": "dbo" } ] } } // all table functions starting from Audit prefix ignored
Provided table functions names should have same casing as actual function name in database. Specifying this option in command line has several limitations and it is recommended to us
e JSON for it instead:
- there is no way to specify schema name for table function;
- table function name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- table function schema (schema property);
- regular expression (regex property) instead of exact table function name (name property).
JSON list element schema:
{
"name" : string // table function name
"schema": string? // table function schema (optional)
}
|
{
"regex" : string // table function name matching regular expression
"schema": string? // table function schema (optional)
}
|
string // also you can put table function name as string directly to list
--include-scalar-functions : only load scalar functions with specified name(s)
type: (string | object) list (optional)
cannot use with: --exclude-scalar-functions
json: schema.include-scalar-functions
examples:
--include-scalar-functions GetUsers,GetRoles,LoadPermissions
JSON examples:
{ "schema": { "include-scalar-functions": [ "ActiveUsers", { "name": "InactiveUsers", "schema": "dbo" } ] } } // ActiveUsers and dbo.InactiveUsers functions
{ "schema": { "include-scalar-functions": [ { "regex": "^Query.+$", "schema": "dbo" } ] } } // all scalar functions starting from Query prefix
Provided scalar functions names should have same casing as actual function name in database. Specifying this option in command line has several limitations and it is recommended to u
se JSON for it instead:
- there is no way to specify schema name for scalar function;
- scalar function name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- scalar function schema (schema property);
- regular expression (regex property) instead of exact scalar function name (name property).
JSON list element schema:
{
"name" : string // scalar function name
"schema": string? // scalar function schema (optional)
}
|
{
"regex" : string // scalar function name matching regular expression
"schema": string? // scalar function schema (optional)
}
|
string // also you can put scalar function name as string directly to list
--exclude-scalar-functions : skip load of scalar functions with specified name(s)
type: (string | object) list (optional)
cannot use with: --include-scalar-functions
json: schema.exclude-scalar-functions
examples:
--exclude-scalar-functions GetUsers,GetRoles,LoadPermissions
JSON examples:
{ "schema": { "exclude-scalar-functions": [ "TestFunction", { "name": "CheckDb", "schema": "dbo" } ] } } // TestFunction and dbo.CheckDb functions ignored
{ "schema": { "exclude-scalar-functions": [ { "regex": "^Audit.+$", "schema": "dbo" } ] } } // all scalar functions starting from Audit prefix ignored
Provided scalar functions names should have same casing as actual function name in database. Specifying this option in command line has several limitations and it is recommended to u
se JSON for it instead:
- there is no way to specify schema name for scalar function;
- scalar function name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- scalar function schema (schema property);
- regular expression (regex property) instead of exact scalar function name (name property).
JSON list element schema:
{
"name" : string // scalar function name
"schema": string? // scalar function schema (optional)
}
|
{
"regex" : string // scalar function name matching regular expression
"schema": string? // scalar function schema (optional)
}
|
string // also you can put scalar function name as string directly to list
--include-aggregate-functions : only load aggregate functions with specified name(s)
type: (string | object) list (optional)
cannot use with: --exclude-aggregate-functions
json: schema.include-aggregate-functions
examples:
--include-aggregate-functions GetUsers,GetRoles,LoadPermissions
JSON examples:
{ "schema": { "include-aggregate-functions": [ "ActiveUsers", { "name": "InactiveUsers", "schema": "dbo" } ] } } // ActiveUsers and dbo.InactiveUsers functions
{ "schema": { "include-aggregate-functions": [ { "regex": "^Query.+$", "schema": "dbo" } ] } } // all aggregate functions starting from Query prefix
Provided aggregate functions names should have same casing as actual function name in database. Specifying this option in command line has several limitations and it is recommended t
o use JSON for it instead:
- there is no way to specify schema name for aggregate function;
- aggregate function name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- aggregate function schema (schema property);
- regular expression (regex property) instead of exact aggregate function name (name property).
JSON list element schema:
{
"name" : string // aggregate function name
"schema": string? // aggregate function schema (optional)
}
|
{
"regex" : string // aggregate function name matching regular expression
"schema": string? // aggregate function schema (optional)
}
|
string // also you can put aggregateaggregate function name as string directly to list
--exclude-aggregate-functions : skip load of aggregate functions with specified name(s)
type: (string | object) list (optional)
cannot use with: --include-aggregate-functions
json: schema.exclude-aggregate-functions
examples:
--exclude-aggregate-functions GetUsers,GetRoles,LoadPermissions
JSON examples:
{ "schema": { "exclude-aggregate-functions": [ "TestFunction", { "name": "CheckDb", "schema": "dbo" } ] } } // TestFunction and dbo.CheckDb functions ignored
{ "schema": { "exclude-aggregate-functions": [ { "regex": "^Audit.+$", "schema": "dbo" } ] } } // all aggregate functions starting from Audit prefix ignored
Provided aggregate functions names should have same casing as actual function name in database. Specifying this option in command line has several limitations and it is recommended t
o use JSON for it instead:
- there is no way to specify schema name for aggregate function;
- aggregate function name cannot have comma (,) as it is used as list separator;
- only exact match possible;
JSON allows you to specify more options:
- aggregate function schema (schema property);
- regular expression (regex property) instead of exact aggregate function name (name property).
JSON list element schema:
{
"name" : string // aggregate function name
"schema": string? // aggregate function schema (optional)
}
|
{
"regex" : string // aggregate function name matching regular expression
"schema": string? // aggregate function schema (optional)
}
|
string // also you can put aggregate function name as string directly to list
=== Data Model : data model configuration
--include-db-name : include database name into generated mappings
type: bool (optional)
json: dataModel.include-db-name
default: false
default (T4 mode): false
--include-default-schema-name : include default schema(s) name into generated mappings
type: bool (optional)
json: dataModel.include-default-schema-name
default: false
default (T4 mode): true
--metadata : specify type of generated metadata
type: string (optional)
json: dataModel.metadata
default: attributes
default (T4 mode): attributes
supported values:
none : don't emit metadata for model
attributes : annotate model with mapping attributes
fluent : annotate model using fluent mapping
--base-entity : base class for generated entities
type: string (optional)
json: dataModel.base-entity
examples:
--base-entity My.Namespace.MyBaseEntity
--base-entity My.Namespace.ParentClass+MyBaseNestedEntity
JSON examples:
{ "dataModel": { "base-entity": "My.Namespace.MyBaseEntity" } }
{ "dataModel": { "base-entity": "My.Namespace.ParentClass+MyBaseNestedEntity" } }
--include-datatype : include DataType enum value to column mappings
type: bool (optional)
json: dataModel.include-datatype
default: false
default (T4 mode): false
--include-db-type : include database type to column mappings
type: bool (optional)
json: dataModel.include-db-type
default: false
default (T4 mode): false
--include-length : include database type length/size to column mappings
type: bool (optional)
json: dataModel.include-length
default: false
default (T4 mode): false
--include-precision : include database type precision to column mappings
type: bool (optional)
json: dataModel.include-precision
default: false
default (T4 mode): false
--include-scale : include database type scale to column mappings
type: bool (optional)
json: dataModel.include-scale
default: false
default (T4 mode): false
--include-db-info : generate comment on data context with database information
type: bool (optional)
json: dataModel.include-db-info
default: false
default (T4 mode): false
Information includes database name, data source and server version (when database provider expose this information).
--add-default-ctor : generate default constructor on data context
type: bool (optional)
json: dataModel.add-default-ctor
default: true
default (T4 mode): true
--add-configuration-ctor : generate data context contructor with configuration name parameter
type: bool (optional)
json: dataModel.add-configuration-ctor
default: true
default (T4 mode): true
Constructor example: public MyDataContext(string context) { ... }
--add-options-ctor : generate data context contructor with options parameter
type: bool (optional)
json: dataModel.add-options-ctor
default: false
default (T4 mode): true
Constructor example: public MyDataContext(DataOptions options) { ... }
--add-typed-options-ctor : generate data context contructor with generic options parameter
type: bool (optional)
json: dataModel.add-typed-options-ctor
default: true
default (T4 mode): true
Constructor example: public MyDataContext(DataOptions<MyDataContext> options) { ... }
--context-name : class name for generated data context
type: string (optional)
json: dataModel.context-name
default: MyDataContext
default (T4 mode): MyDataContext
When not specified, database name used. When database name not available, "MyDataContext" used
--base-context : base class for generated data context
type: string (optional)
json: dataModel.base-context
default: LinqToDB.Data.DataConnection
default (T4 mode): LinqToDB.Data.DataConnection
examples:
--base-context LinqToDB.DataContext
JSON examples:
{ "dataModel": { "base-context": "LinqToDB.DataContext" } }
--context-modifier : access modifier for generated data context
type: string (optional)
json: dataModel.context-modifier
default: public
default (T4 mode): public
supported values:
private : applies 'public' to data context class
internal : applies 'internal' to data context class
public : applies 'private' to data context class
examples:
--context-modifier internal
JSON examples:
{ "dataModel": { "context-modifier": "internal" } }
--add-init-context : generate InitDataContext partial method on data context for custom context setup
type: bool (optional)
json: dataModel.add-init-context
default: true
default (T4 mode): true
--add-static-init-context : generate StaticInitDataContext partial method on data context for custom context setup
type: bool (optional)
json: dataModel.add-static-init-context
default: false
default (T4 mode): false
Method will be called from generated context's static constructor after all other code. Enabling this option will force static constructor generation.
--add-associations : generate association properties on entities
type: bool (optional)
json: dataModel.add-associations
default: true
default (T4 mode): true
--add-association-extensions : generate association extension methods for entities
type: bool (optional)
json: dataModel.add-association-extensions
default: false
default (T4 mode): false
--association-collection : collection type to use for many-sided associations
type: string (optional)
json: dataModel.association-collection
default: System.Collections.Generic.IEnumerable<>
default (T4 mode): System.Collections.Generic.IEnumerable<>
examples:
--association-collection []
--association-collection System.Collections.Generic.List<>
JSON examples:
{ "dataModel": { "association-collection": "[]" } }
{ "dataModel": { "association-collection": "System.Collections.Generic.List<>" } }
Should be open-generic type with one parameter or [] for array
--reuse-entities-in-procedures : allows use of entity mapping for return type of stored procedure/table function
type: bool (optional)
json: dataModel.reuse-entities-in-procedures
default: true
default (T4 mode): true
When procedure/function schema has same columns (by name, type and nullability) as known table/view entity, this option allows to use entity mapping for procedure/function return typ
e. Otherwise separate mapping class will be generated for specific procedure/function.
--table-function-returns-table : table functions use ITable<T> as return type, otherwise IQueryable<T> type used
type: bool (optional)
json: dataModel.table-function-returns-table
default: false
default (T4 mode): true
--emit-schema-errors : generate #error pragma for stored procedures and table functions with schema load errors
type: bool (optional)
json: dataModel.emit-schema-errors
default: false
default (T4 mode): false
--procedure-types : enables generation of sync and async versions of stored procedure mapping
type: string list (optional)
json: dataModel.procedure-types
default: sync, async
default (T4 mode): sync
supported values:
sync : generate sync stored procedure call mappings
async : generate async stored procedure call mappings
--skip-procedures-with-schema-errors : skips mapping generation for stored procedure with schema load errors, otherwise generate mapping without result table
type: bool (optional)
json: dataModel.skip-procedures-with-schema-errors
default: false
default (T4 mode): true
--procedure-returns-list : use List<T> for stored procedure return dataset, otherwise IEnumerable<T> used
type: bool (optional)
json: dataModel.procedure-returns-list
default: false
default (T4 mode): false
--add-db-type-to-procedures : include database type to stored procedure parameters
type: bool (optional)
json: dataModel.add-db-type-to-procedures
default: false
default (T4 mode): false
--schema-as-type : generate non-default schemas' code nested into separate class
type: bool (optional)
json: dataModel.schema-as-type
default: true
default (T4 mode): false
--equatable-entities : entity classes will implement IEquatable<T> interface using primary key column(s) for identity calculation. Requires reference to linq2db.Tools nuget from generated code.
type: bool (optional)
json: dataModel.equatable-entities
default: false
default (T4 mode): false
--find-methods : enable generation of extension methods to access entity by primary key
type: string list (optional)
json: dataModel.find-methods
default: sync-pk-table, async-pk-table
default (T4 mode): sync-pk-table
supported values:
none : disable generation of Find extensions. Cannot be used with other values
sync-pk-table : generate sync entity load extension on table object with primary key parameters: Entity? Find (this ITable<Entity> table, pk_fields)
async-pk-table : generate sync entity load extension on table object with primary key parameters: Task<Entity?> FindAsync(this ITable<Entity> table, pk_fields, CancellationToken)
query-pk-table : generate entity query extension on table object with primary key parameters : IQueryable<Entity> FindQuery(this ITable<Entity> table, pk_fields)
sync-pk-context : generate sync entity load extension on table object with primary key parameters: Entity? Find (this DataContext db , pk_fields)
async-pk-context : generate sync entity load extension on table object with primary key parameters: Task<Entity?> FindAsync(this DataContext db , pk_fields, CancellationToken)
query-pk-context : generate entity query extension on table object with primary key parameters : IQueryable<Entity> FindQuery(this DataContext db , pk_fields)
sync-entity-table : generate sync entity load extension on table object with entity parameter : Entity? Find (this ITable<Entity> table, Entity row)
async-entity-table : generate sync entity load extension on table object with entity parameter : Task<Entity?> FindAsync(this ITable<Entity> table, Entity row, CancellationToken)
query-entity-table : generate entity query extension on table object with entity parameter : IQueryable<Entity> FindQuery(this ITable<Entity> table, Entity row)
sync-entity-context : generate sync entity load extension on generated context with entity parameter : Entity? Find (this DataContext> db , Entity row)
async-entity-context : generate sync entity load extension on generated context with entity parameter : Task<Entity?> FindAsync(this DataContext db , Entity row, CancellationToken)
query-entity-context : generate entity query extension on generated context with entity parameter : IQueryable<Entity> FindQuery(this DataContext db , Entity row)
--order-find-parameters-by-ordinal : use primary key column ordinal to order Find() extension method parameters (composite primary key only)
type: bool (optional)
json: dataModel.order-find-parameters-by-ordinal
default: true
default (T4 mode): false
--partial-entities : when set to true, generates partial class modifier on entity mapping classes
type: bool (optional)
json: dataModel.partial-entities
default: false
default (T4 mode): true
--schema-class-names : provides schema context class/property names for non-default schemas (appliable only if schema-as-type option enabled)
type: [string]: string (optional)
json: dataModel.schema-class-names
examples:
--schema-class-names schema1=SchemaOne,schema2=SpecialSchema
JSON examples:
{ "dataModel": { "schema1": "SchemaOne", "schema2": "SpecialSchema" } }
Without this option schema name will be used as base name to generate schema context/property names. Specifying this option in command line has limitations and it is recommended to u
se JSON for it instead because names in CLI cannot contain comma (,) or equality (=) characters, as they used as separators.
--fluent-entity-type-helpers : Enables generation of entity builder extension method calls for each fluent entity builder.
type: string list (optional)
json: dataModel.fluent-entity-type-helpers
default:
default (T4 mode):
Enabling this requires one or more extension methods, with same name, taking "this EntityMappingBuilder<T> builder" as first parameter and nullable entity value (passed as null) as s
econd parameter. Entity parameter type could be specific or generic type.
E.g. following example defines two fluent mapping helpers:
- ConfigureEntity is a set of methods, with entity parameter constrained to specific type or interface and optional fallback method to handle other types.
- ConfigureAllEntities is a single method that accept any entity
static class CustomFluentExtensions
{
// called for builder of specific entity type or it's childs only
internal static EntityMappingBuilder<T> ConfigureEntity<T>(this EntityMappingBuilder<T> builder, Person? _) where T : Person => ...;
// called for builder of entities with specific interface
internal static EntityMappingBuilder<T> ConfigureEntity<T>(this EntityMappingBuilder<T> builder, Child? _) where T : IEntities => ...;
// called for all other entities. As example it annotated with Obsolete attribute to catch new entities not convered by methods above in build-time
[Obsolete("Define ConfigureEntity method for this entity type")]
internal static EntityMappingBuilder<T> ConfigureEntity<T>(this EntityMappingBuilder<T> builder, T? _) where T : class => ...;
// single method to call for all entity builder to perform generic configuration or dispatch entity configuration by type dynamically by method itself
internal static EntityMappingBuilder<T> ConfigureAllEntities<T>(this EntityMappingBuilder<T> builder, T? _) where T : class => ...;
}
data-context-class-name : (allowed only in JSON) data context class naming options (for auto-generated names only)
type: object (optional)
json: dataModel.data-context-class-name
default: {
"case" : "pascal_case",
"pluralization" : "none",
"prefix" : null,
"suffix" : null,
"transformation" : "split_by_underscore",
"pluralize_if_ends_with_word_only": false,
"ignore_all_caps" : false,
}
default (T4 mode): {
"case" : "pascal_case",
"pluralization" : "none",
"prefix" : null,
"suffix" : null,
"transformation" : "split_by_underscore",
"pluralize_if_ends_with_word_only": false,
"ignore_all_caps" : false,
}
JSON examples:
{
"dataModel":
{
"data-context-class-name":
{
"case" : "pascal_case",
"pluralization": "singular",
"suffix" : "Record"
}
}
}
Naming options could be specified only in JSON file and defined as object with following properties:
- case : string : specify name casing (see values below)
+ "none" : no casing applied to identifier
+ "pascal_case" : identifier cased using PascalCase
+ "camel_case" : identifier cased using camelCase
+ "snake_case" : identifier cased using snake_case