-
Notifications
You must be signed in to change notification settings - Fork 8
/
PocosGenerator.csx
39 lines (31 loc) · 1.32 KB
/
PocosGenerator.csx
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
#! "netcoreapp2.1"
#load "PocosGenerator.Core.csx"
//when running from VS Code, set your options here
if (!Args.Any()){
options.Output = "DbModels.cs";
options.ConfigFilePath = @"..\Config\connectionstrings.json";
options.Namespace = "Db.Models";
options.ConnectionStringName = "ConnectionStrings:Data";
options.SpClass = "spData";
options.TvpClass = "tvpData";
}
var generator = new PocosGenerator(options);
WriteLine($"Connecting to database: {zap_password(generator.ConnectionString)}");
if (generator.ReadSchema()){
// Let's remove ignore for tables and views we need
/*
generator.Tables["tablename"].Ignore = false;
*/
/*
// Tweak Schema
generator.Tables["tablename"].Ignore = true; // To ignore a table
generator.Tables["tablename"].ClassName = "newname"; // To change the class name of a table
generator.Tables["tablename"]["columnname"].Ignore = true; // To ignore a column
generator.Tables["tablename"]["columnname"].PropertyName="newname"; // To change the property name of a column
generator.Tables["tablename"]["columnname"].PropertyType="bool"; // To change the property type of a column
*/
generator.GenerateClass();
}
WriteLine($"Attempting to write generated content to {options.Output}");
System.IO.File.WriteAllText(options.Output, generator.Content);
WriteLine("Finished.");