BulkDataSeeder.EfCore
1.0.0
See the version list below for details.
dotnet add package BulkDataSeeder.EfCore --version 1.0.0
NuGet\Install-Package BulkDataSeeder.EfCore -Version 1.0.0
<PackageReference Include="BulkDataSeeder.EfCore" Version="1.0.0" />
paket add BulkDataSeeder.EfCore --version 1.0.0
#r "nuget: BulkDataSeeder.EfCore, 1.0.0"
// Install BulkDataSeeder.EfCore as a Cake Addin
#addin nuget:?package=BulkDataSeeder.EfCore&version=1.0.0
// Install BulkDataSeeder.EfCore as a Cake Tool
#tool nuget:?package=BulkDataSeeder.EfCore&version=1.0.0
BulkDataSeeder.EfCore
Introduction :
BulkDataSeeder.EfCore is a versatile library that simplifies the process of seeding data into multiple database systems using Entity Framework Core. It supports SQL Server, MySQL, and PostgreSQL, making it an ideal choice for projects with diverse database requirements.
GetStarted
Features
- Multi-Database Support: Seamlessly seed data into SQL Server, MySQL, and PostgreSQL databases.
- Entity Framework Core Integration: Utilizes the power of Entity Framework Core for efficient data operations.
- Easy Configuration: Simple setup and configuration using JSON files.
- Bulk Insert or Update: Efficiently inserts or updates data in bulk, reducing database round-trips.
Installation
You can install this package via NuGet. Use the following command:
nuget install BulkDataSeeder.EfCore
Prerequisties
Install the appropriate database packages and configure this code in Startup.cs
var dbContext = new YourDbContext();
var dataSeeder = new DataSeeder<YourDbContext>(dbContext);
Initialize your Entity Framework Core DbContext and use the below code
Prepare Your Data
Create CSV files for each table you want to seed and store them in a directory (e.g., "YOUR").
Create a JSON configuration file (e.g., "YOUR-CSV-ORDER-CONFIGURATION_FILE_NAME.json") that specifies the order in which the CSV files should be processed.
Sample JSON Configuration
[
{
"FileName": "Table1.csv",
"Order": 1
},
{
"FileName": "Table2.csv",
"Order": 2
}
]
- Create a DataSeeder instance
using (var dbContext = new YourDbContext(options))
{
var dataseeder = new DataSeeder<AppDbContext>(dbContext);
string fullPath = Path.Combine(Directory.GetCurrentDirectory(), "YOUR-CSV-FOLDER-NAME");
if (!Directory.Exists(fullPath))
{
Console.WriteLine($"Directory not found: {fullPath}");
return;
}
// Read the configuration file
string configFile = Path.Combine(fullPath, "YOUR-CSV-ORDER-CONFIGURATION_FILE_NAME");
if (!File.Exists(configFile))
{
Console.WriteLine($"Configuration file not found: {configFile}");
return;
}
dataseeder.PublishCsvData(fullPath, configFile);
}
Enjoy Bulk Seeding
BulkDataSeeder.EfCore will efficiently insert or update data in your specified databases, using the appropriate SQL statements for each database system.
Contributing
Contributions are welcome! If you encounter issues or have suggestions for improvements, please open an issue or create a pull request on our GitHub repository.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net6.0
- CsvHelper (>= 30.0.1)
- Microsoft.EntityFrameworkCore (>= 7.0.10)
- Microsoft.EntityFrameworkCore.SqlServer (>= 7.0.10)
- Npgsql.EntityFrameworkCore.PostgreSQL (>= 7.0.4)
- Npgsql.EntityFrameworkCore.PostgreSQL.Design (>= 1.1.0)
- Pomelo.EntityFrameworkCore.MySql (>= 7.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
BulkDataSeeder.EfCore is a versatile library that simplifies the process of seeding data into multiple database systems using Entity Framework Core. It supports SQL Server, MySQL, and PostgreSQL, making it an ideal choice for projects with diverse database requirements.