DefaultTestDataForTask categories:
using MyProject. The Tasks;
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. The Text;
The namespace MyProject. EntityFrameworkCore. Seed. Host
{
Public class DefaultTestDataForTask
{
Private readonly MyProjectDbContext _context;
Private static readonly List_tasks;
Public DefaultTestDataForTask (MyProjectDbContext context)
{
_context=context;
}
The static DefaultTestDataForTask ()
{
_tasks=new List()
{
New Task (" Learning ABP deom ", "Learning how to use ABP framework to build a MPA application"),
New Task (" Make Lunch ", "Cook 2 dishs")
};
}
Public void the Create ()
{
The foreach (var task in _tasks)
{
If (_context. Tasks. FirstOrDefault (t=& gt; T.T itle==task. The Title)==null)
{
_context. The Tasks. The Add (task);
}
_context. SaveChanges ();
}
}
}
}
InitialHostDbBuilder categories:
public void the Create ()
{
New DefaultEditionCreator (_context). The Create ();
New DefaultLanguagesCreator (_context). The Create ();
New HostRoleAndUserCreator (_context). The Create ();
New DefaultSettingsCreator (_context). The Create ();
New DefaultTestDataForTask (_context). The Create ();
_context. SaveChanges ();
}
Table after the update has been successfully created, but there is no data in the table
Break for two days, still won't do, not much, also please feel free to comment ~ ~ ~
CodePudding user response:
Your top one ~