Repository navigation
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (45 loc) · 1.67 KB
/
Copy pathProgram.cs
File metadata and controls
53 lines (45 loc) · 1.67 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
using Insight.Database.Schema;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace CodeWithMe.Setup
{
/// <summary>
/// Entry point.
/// </summary>
class Program
{
/// <summary>
/// Launch the insight schema setup.
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
Console.WriteLine("Beginning to setup the database.");
var connectionString = ConfigurationManager.ConnectionStrings["CodeWithMe"].ConnectionString;
// Will actually create the database if it doesn't exist!
SchemaInstaller.CreateDatabase(connectionString);
// Invoke the schema installer to do magic.
using (var db = new SqlConnection(connectionString))
{
db.Open();
// create the installer to apply changes
SchemaInstaller installer = new SchemaInstaller(db);
new SchemaEventConsoleLogger().Attach(installer);
// get the SQL from the embedded resources
SchemaObjectCollection schema = new SchemaObjectCollection(Assembly.GetExecutingAssembly());
schema.StripPrintStatements = true;
// install the schema
// (This allows us to have multiple schemas in a single database. Pretty cool).
installer.Install("CodeWithMe", schema);
}
Console.WriteLine();
Console.WriteLine("Done!");
}
}
}