Hello everyone,
How to import json in asp.net core
However i would like to do same operation from json to this method seed data.
Because i have to import large number data for example i would like to import list of countries from json.
How can i do it in asp.net core?
in my asp.net core application normally i seed data below way
public class AcDispatchingMethodConfiguration : BaseEntityConfiguration<AcDispatchingMethod>
{
protected override void ConfigureEntity(EntityTypeBuilder<AcDispatchingMethod> builder)
{
builder.Property(e => e.Description).HasMaxLength(100).IsRequired();
builder.Property(e => e.Id).ValueGeneratedNever();
builder.Ignore(e => e.AcDispatchingMethodEnum);
builder.ToTable("AcDispatchingMethods");
SeedData(builder);
}
private void SeedData(EntityTypeBuilder<AcDispatchingMethod> builder)
{
builder.HasData(
new AcDispatchingMethod
{
Id = (int) AcDispatchingMethodEnum.None,
Description = "NONE",
CreatedAt = DateTime.Now,
CreatedBy = "SYSTEM"
},
new AcDispatchingMethod
{
Id = (int) AcDispatchingMethodEnum.Email,
Description = "EMAIL",
CreatedAt = DateTime.Now,
CreatedBy = "SYSTEM"
},
new AcDispatchingMethod
{
Id = (int) AcDispatchingMethodEnum.Mail,
Description = "MAIL",
CreatedAt = DateTime.Now,
CreatedBy = "SYSTEM"
},
new AcDispatchingMethod
{
Id = (int) AcDispatchingMethodEnum.Web,
Description = "WEB",
CreatedAt = DateTime.Now,
CreatedBy = "SYSTEM"
}
);
}
}