Home > Net >  Asp.Net Abp Core reserved seed cannot be written to the database
Asp.Net Abp Core reserved seed cannot be written to the database

Time:09-27

Learning Abp framework, has been unable to insert the reserved seed database, don't know what is the problem? Steps to follow online tutorial to ~


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 ~
  • Related