Stream migration commands
Nobody has claimed this yet.
Assessment
This issue has not been assessed yet.
Description
When using migrationBuilder.InsertData(... to insert seed data, there is a memory leak of Microsoft.EntityFrameworkCore.Storage.RelationalCommand.
I batch insert the data in 1,000 item page (max supported).
Reproduce (insert 18,250 rows):
int pageSize = 1000;
var startDate = new DateTime(1990, 01, 01);
var endDate = new DateTime(2040, 12, 31);
var dateValueCount = (endDate - startDate).Days;
var dateData = new object[dateValueCount + 1, 6];
for (DateTime date = startDate; date <= endDate; date = date.AddDays(1))
{
var dateIndex = (date - startDate).Days;
dateData[dateIndex, 0] = date.Date;
dateData[dateIndex, 1] = (byte)date.Day;
dateData[dateIndex, 2] = (byte)CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(date, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);
dateData[dateIndex, 3] = (byte)date.Month;
dateData[dateIndex, 4] = (byte)((date.Month + 2) / 3);
dateData[dateIndex, 5] = (Int16)date.Year;
}
int currentDatePage = 0;
while ((currentDatePage * pageSize) < dateData.GetLength(0))
{
var startIndex = currentDatePage * pageSize;
var endIndex = dateData.GetLength(0) < startIndex + pageSize ? startIndex + dateData.GetLength(0) - startIndex : startIndex + pageSize;
var dataPart = new object[endIndex - startIndex, 6];
for (int i = startIndex; i < endIndex; i++)
{
dataPart[i - startIndex, 0] = dateData[i, 0];
dataPart[i - startIndex, 1] = dateData[i, 1];
dataPart[i - startIndex, 2] = dateData[i, 2];
dataPart[i - startIndex, 3] = dateData[i, 3];
dataPart[i - startIndex, 4] = dateData[i, 4];
dataPart[i - startIndex, 5] = dateData[i, 5];
migrationBuilder.InsertData(
table: "Date",
schema: "dim",
columns: new string[]
{
"Date",
"Day",
"Week",
"Month",
"Quarter",
"Year"
},
values: dataPart);
}
currentDatePage++;
}
Environment: Net Core 3.1, EF Core 3.1.1
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 134
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from dotnet/efcore
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
customer-reported
Difficulty 5/5 Over a week Newbie friendliness 38/100
-
area-cosmos area-vector-search
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-cosmos
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area-tools needs-design
Difficulty 4/5 3-5 days Newbie friendliness 25/100
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
:watch: Not Triaged 11.0 fundamentals/subsvc
Difficulty 2/5 1-3 hours Newbie friendliness 92/100
dotnet/AspNetCore.Docs#37699 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
SubtitleEdit/subtitleedit#15108 · 1 comment ·
-
area/docs-content Bug pulumi/docs
Difficulty 1/5 1-3 hours Newbie friendliness 94/100
-
agentic-workflows untriaged
Difficulty 2/5 1-3 hours Newbie friendliness 76/100