Forum-Inzynieria1/Trunk/Server/Forum/Forum.DataAccessLayer/Migrations/Configuration.cs
2018-12-19 12:55:35 +01:00

44 lines
1.3 KiB
C#

using System.Collections.Generic;
using System.Data.Entity.Migrations;
using Forum.DataAccessLayer.Models;
namespace Forum.DataAccessLayer.Migrations
{
using System;
using System.Linq;
internal sealed class Configuration : DbMigrationsConfiguration<Forum.DataAccessLayer.ApplicationDbContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
}
protected override void Seed(Forum.DataAccessLayer.ApplicationDbContext context)
{
if (!context.Categories.Any(c=>c.CategoryName=="Zwroty"))
{
var zwroty = new Category()
{
CategoryName = "Zwroty",
Questions = new List<Question>()
{
new Question()
{
Title = "Jak dokonaæ zwrotu",
Content = "Chce dostaæ zwrot nwm co robic pls admian halp!11",
IsClosed = false,
PostDate = DateTime.Now,
Nick = "Potrzebuj¹cy"
}
}
};
context.Categories.Add(zwroty);
context.SaveChanges();
}
}
}
}