Conversion Reference
This document details the specific code transformations performed by the Entity Framework Core migration tool for Epicor customizations.
Overview
This tool converts legacy Epicor custom code from Entity Framework 6 (EF6) to Entity Framework Core (EF Core) using Roslyn code analysis and rewriting.
It processes:
- BPM Directives (Business Process Management custom code)
- Epicor Functions (custom function libraries)
- Product Configurator rules
- Electronic Interfaces (EDI/integration customizations)
1. What It Converts (Replaces)
1.1 Namespace Replacements
| EF6 Namespace | EF Core Replacement |
|---|---|
System.Data.Entity |
Microsoft.EntityFrameworkCore |
System.Data.Entity.SqlServer |
Microsoft.EntityFrameworkCore |
What Happens
- Using directives are replaced (old ones commented out)
- Fully qualified names are rewritten
Example
// BEFORE
using System.Data.Entity;
// AFTER
// using System.Data.Entity;
using Microsoft.EntityFrameworkCore;
1.2 DbFunctions Method Replacements
EF6’s DbFunctions methods are converted to EF Core equivalents.
Date Arithmetic Methods
| EF6 Method | EF Core Replacement |
|---|---|
DbFunctions.AddDays(date, days) |
date.AddDays(days) or date.Value.AddDays(days) |
DbFunctions.AddMonths(date, months) |
date.AddMonths(months) or date.Value.AddMonths(months) |
Date Difference Methods
| EF6 Method | EF Core Replacement |
|---|---|
DbFunctions.DiffDays(start, end) |
EF.Functions.DateDiffDay(start, end) |
DbFunctions.DiffHours(start, end) |
EF.Functions.DateDiffHour(start, end) |
DbFunctions.DiffMinutes(start, end) |
EF.Functions.DateDiffMinute(start, end) |
DbFunctions.DiffSeconds(start, end) |
EF.Functions.DateDiffSecond(start, end) |
DbFunctions.DiffMonths(start, end) |
EF.Functions.DateDiffMonth(start, end) |
DbFunctions.DiffYears(start, end) |
EF.Functions.DateDiffYear(start, end) |
Date Truncation Methods
| EF6 Method | EF Core Replacement |
|---|---|
DbFunctions.TruncateTime(date) |
date.Date or date.Value.Date |
Notes
- Automatically handles nullable versus non-nullable
DateTimevalues - Fully qualified
DbFunctionscalls are rewritten to useMicrosoft.EntityFrameworkCore.SqlServerDbFunctionsExtensions - Simple
DbFunctionscalls are rewritten to useEF.Functions
1.3 LINQ Default Methods
Methods with default-value parameters are converted because EF Core does not support those overloads.
| Method | Transformation |
|---|---|
FirstOrDefault(defaultValue) |
Removes the defaultValue parameter when it is a literal default |
LastOrDefault(defaultValue) |
Removes the defaultValue parameter |
SingleOrDefault(defaultValue) |
Removes the defaultValue parameter |
DefaultIfEmpty(defaultValue) |
Removes the defaultValue parameter |
Supported literal defaults:
nullfalse0
Example
// BEFORE
var result = query.FirstOrDefault(null);
// AFTER
var result = query.FirstOrDefault();
Warning Generated
If the default value is not a simple literal (null, false, or 0), a diagnostic warning is generated for manual review.
1.4 String Function Overload Removal
Culture-specific string comparison overloads are removed from LINQ queries because EF Core does not support them.
Methods Affected
String.Compare()String.Contains()String.Equals()String.StartsWith()String.EndsWith()
Removed Parameters
String.Compare()
Removes:
StringComparisonCultureInfoCompareOptions
Other Methods
Removes:
StringComparison
Applies Only When
- The method is used inside a LINQ query expression
- The method includes non-string or non-char comparison parameters
2. What It Deletes
2.1 Assembly References
Removed from BPM Directive XML
EntityFramework.dllEntityFramework.SqlServer.dll
Removed from Function Library References
DELETE FROM Ecf.EfxLibraryReference
WHERE LibraryID = @libraryId
AND ReferenceID IN (
'EntityFramework.dll',
'EntityFramework.SqlServer.dll'
)
2.2 Using Directives
The following directives are removed and commented out:
using System.Data.Entity;
using System.Data.Entity.SqlServer;
3. What It Comments Out
3.1 Identity Column Assignments
Assignments to auto-increment (identity) columns are commented out because EF Core does not allow explicit identity value updates.
Example
// BEFORE
row.ABTAmountUID = 123;
row.MtlQueueSeq++;
// AFTER
// row.ABTAmountUID = 123;
// row.MtlQueueSeq++;
Common Identity Columns
ABTAmountUIDABTDocLineUIDMtlQueueSeqTranNumHeadNumSequenceAttributeSetIDDeferredSeq
Operations Commented Out
- Assignment (
=) - Increment (
++) - Decrement (
--) - Compound assignment (
+=,-=, etc.)
Scope
More than 180 Epicor tables with identity columns are analyzed.
4. What It Validates (Warnings and Errors)
4.1 Warnings
ECF9002
The 'FirstOrDefault' function that takes a default value is not supported in EF Core.
Generated when a LINQ default method uses a non-literal default value.
ECF9001
The value of the identity column {TableName}.{ColumnName} is set by the database. Do not set it in code.
Generated when code attempts to assign an identity column value.
4.2 Errors
ECF9003
The DbFunction '{MethodName}' is not supported in EF Core.
Generated for unsupported EF6 database functions.
ECF9004
The method overload is not supported in EF Core LINQ queries.
Generated for unsupported string-comparison overloads.
5. Conversion Results
Success States
Fully Converted
Code updated successfully and compiles under EF Core.
Partially Converted
Code updated, but warnings were generated and manual review is required.
Not Modified
No EF6-specific code was detected.
Failure States
Conversion Failed
EF6 code was detected but could not be automatically converted. The database is not updated.
Error During Processing
An exception occurred during conversion.
Backup and Rollback
Original Code Preservation
Original source code is preserved in all conversion messages.
Electronic Interfaces
Backup files are written to the Company/EI folder.
BPM Directives and Functions
Original source code is included in conversion logs.
6. What Requires Manual Review
The converter flags the following scenarios for manual intervention:
- Unsupported
DbFunctions - Non-literal default values in LINQ methods
- Complex culture-specific string comparisons
- Identity column assignment logic
- Custom EF6 extensions not recognized by the converter