Skip to content

Instantly share code, notes, and snippets.

@mikecousins
Created January 4, 2013 20:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikecousins/4455831 to your computer and use it in GitHub Desktop.
Save mikecousins/4455831 to your computer and use it in GitHub Desktop.
using System.Data.Entity;
using Shuttr.Domain.Entities;
using System.Linq;
using System.Collections.Generic;
namespace Shuttr.Domain.Contexts
{
/// <summary>
/// The database initializer
/// </summary>
public static class ShuttrDbInitializer
{
/// <summary>
/// Seeds our database with initial values
/// </summary>
/// <param name="context">The database context</param>
public static void Seed()
{
var context = new ShuttrEntities();
// add account types
if (context.AccountTypes.Count() == 0)
{
AccountType mini = new AccountType { Name = "Mini", CanSellPrints = false, StorageSizeMb = 250 };
context.AccountTypes.Add(mini);
AccountType plus = new AccountType { Name = "Plus", CanSellPrints = false, StorageSizeMb = 50000 };
context.AccountTypes.Add(plus);
AccountType pro = new AccountType { Name = "Pro", CanSellPrints = true, StorageSizeMb = 100000 };
context.AccountTypes.Add(pro);
}
// add products
if (context.Products.Count() == 0)
{
Product fourBySix = new Product { Name = "4x6" };
context.Products.Add(fourBySix);
Product fiveBySeven = new Product { Name = "5x7" };
context.Products.Add(fiveBySeven);
Product eightByTen = new Product { Name = "8x10" };
context.Products.Add(eightByTen);
Product eightByTwelve = new Product { Name = "8x12" };
context.Products.Add(eightByTwelve);
Product twelveByEighteen = new Product { Name = "12x18" };
context.Products.Add(twelveByEighteen);
Product twentyByThirty = new Product { Name = "20x30" };
context.Products.Add(twentyByThirty);
Product digital = new Product { Name = "Digital" };
context.Products.Add(digital);
Product wallpaper = new Product { Name = "Wallpaper" };
context.Products.Add(wallpaper);
}
// save the changes
context.SaveChanges();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment