The next generation of the Teknik Services. Written in ASP.NET. https://www.teknik.io/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

SampleData.cs 925B

12345678910111213141516171819202122232425262728293031
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data.Entity;
  4. namespace Teknik.Models
  5. {
  6. public class SampleData : DropCreateDatabaseIfModelChanges<TeknikEntities>
  7. {
  8. protected override void Seed(TeknikEntities context)
  9. {
  10. var user = new User
  11. {
  12. Username = "Uncled1023",
  13. JoinDate = DateTime.Now,
  14. LastSeen = DateTime.Now
  15. };
  16. context.Users.Add(user);
  17. var posts = new List<Post>
  18. {
  19. new Post { Article = "Test Post", DatePosted = DateTime.Now, DatePublished = DateTime.Now, Title = "Test Post", Published = false}
  20. };
  21. posts.ForEach(post => context.Posts.Add(post));
  22. new List<Blog>
  23. {
  24. new Blog {Posts = posts, User = user}
  25. }.ForEach(blog => context.Blogs.Add(blog));
  26. }
  27. }
  28. }