-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
44 lines (39 loc) · 1.48 KB
/
Program.cs
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
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.EntityFrameworkCore;
using System.Configuration;
using Microsoft.Extensions.Configuration;
using EF6Crypto.Models;
namespace EF6Crypto
{
class Program
{
static void Main(string[] args)
{
var DbContextOptions = new CoinContext(GetOptions("Server=.\\SQLEXPRESS;Database=Crypto2;Trusted_Connection=True;"));
using (var cc = DbContextOptions)
{
TestCreate(cc, "Bitcoin", "BTC", "Bitcoin", 6350, "CoinBase");
}
}
public static void TestCreate(CoinContext cc, string CoinName, string CoinTicker, string CoinDescription, float CoinPrice,
string ExchangeName)
{
var coin = new Coin()
{ CoinName = "Ethereum", CoinTicker = "ETH", CoinDescription = "Ethereum", CoinPrice = 202 };
var exchange = new Exchange()
{ ExchangeName = "MtGox" };
var coinExchange = new CoinExchange()
{ Coin = coin, Exchange = exchange };
cc.Coins.Add(coin);
cc.Exchanges.Add(exchange);
cc.CoinExchanges.Add(coinExchange);
cc.SaveChanges();
}
public static DbContextOptions GetOptions(string connectionString)
{
return SqlServerDbContextOptionsExtensions.UseSqlServer(new DbContextOptionsBuilder(), connectionString).Options;
}
}
}