-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBlogContext.cs
More file actions
47 lines (42 loc) · 1.38 KB
/
Copy pathBlogContext.cs
File metadata and controls
47 lines (42 loc) · 1.38 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
namespace Panner.AspNetCore.Samples.FastEndpointsNet9.EFModel
{
using Microsoft.EntityFrameworkCore;
using System;
public class BlogContext : DbContext
{
public DbSet<Post> Posts { get; set; }
public BlogContext() : base()
{
}
public BlogContext(DbContextOptions options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Post>()
.HasData(new Post()
{
Id = 1,
Title = Guid.NewGuid().ToString(),
Content = Guid.NewGuid().ToString(),
CreatedOn = DateTime.UtcNow,
IsVisible = true
}, new Post()
{
Id = 2,
Title = Guid.NewGuid().ToString(),
Content = Guid.NewGuid().ToString(),
CreatedOn = DateTime.UtcNow,
IsVisible = false
}, new Post()
{
Id = 3,
Title = Guid.NewGuid().ToString(),
Content = Guid.NewGuid().ToString(),
CreatedOn = DateTime.UtcNow,
IsVisible = true
});
}
}
}