Add new class to have cleaner code
This commit is contained in:
parent
13e0e77b52
commit
50a11e0434
@ -24,26 +24,7 @@ namespace SessionCompanion.Database
|
|||||||
protected override void OnModelCreating(ModelBuilder builder)
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
{
|
{
|
||||||
base.OnModelCreating(builder);
|
base.OnModelCreating(builder);
|
||||||
builder.Entity<User>().HasData(
|
builder.Entity<User>().HasData(SeedData.SeedUsers());
|
||||||
new
|
|
||||||
{
|
|
||||||
Id = 1,
|
|
||||||
Nickname = "Morwiec",
|
|
||||||
Password = "123"
|
|
||||||
},
|
|
||||||
new
|
|
||||||
{
|
|
||||||
Id = 2,
|
|
||||||
Nickname = "Cichoklepiec",
|
|
||||||
Password = "123"
|
|
||||||
},
|
|
||||||
new
|
|
||||||
{
|
|
||||||
Id = 3,
|
|
||||||
Nickname = "Ruletka",
|
|
||||||
Password = "123"
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
39
SessionCompanion/SessionCompanion.Database/SeedData.cs
Normal file
39
SessionCompanion/SessionCompanion.Database/SeedData.cs
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SessionCompanion.Database.Tables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database
|
||||||
|
{
|
||||||
|
public class SeedData
|
||||||
|
{
|
||||||
|
static public List<User> SeedUsers()
|
||||||
|
{
|
||||||
|
List<User> users = new List<User>
|
||||||
|
{
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Nickname = "Morwiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Nickname = "Cichoklepiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new User
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
Nickname = "Ruletka",
|
||||||
|
Password = "123"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user