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.
WF-PmAPI/WF_EF_Api/StubbedContextLib/StubWTFContext.cs

35 lines
1.2 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Contextlib;
using Entity;
using Microsoft.EntityFrameworkCore;
namespace StubbedContextLib
{
public class StubWTFContext : WTFContext
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Images>()
.HasMany(i => i.Users)
.WithOne(u => u.Images)
.HasForeignKey(u => u.IdImage)
.IsRequired();
modelBuilder.Entity<Images>().HasData(
new Images { Id = 1, ImgPath = "coucou" },
new Images { Id = 2, ImgPath = "bonjour" }
);
modelBuilder.Entity<Users>().HasData(
new Users { Id = 1, UserName = "Dev", Created = new DateTime(2000, 01, 01), Email = "dev@gmail.com", Password = "1234", IdImage = 1 },
new Users { Id = 2, UserName = "Admin", Created = new DateTime(2000, 01, 01), Email = "admin@gmail.com", Password = "1234", IdImage = 1 }
);
}
}
}