Documentation

How to start a new VS project

Article author
Admin
  • Updated

This is an easy-to-follow step-by-step guide on how to create a new Visual Studio project from scratch and begin to translate EDI files. 

Download EdiFabric EDI Tools (including local NuGet packages and DLLs)

Download EdiFabric EDI Tools from GitHub

 

Difference between the trial and the paid version

The EDI templates are the only difference between the trial and the paid version of EDI Tools for .NET.

The trial uses the following prebuilt set of templates:

  • EdiFabric.Templates.X12
  • EdiFabric.Templates.Hipaa
  • EdiFabric.Templates.Edifact
  • EdiFabric.Templates.Hl7
  • EdiFabric.Templates.Ncpdp
  • EdiFabric.Templates.Padis
  • EdiFabric.Templates.Vda

The paid version provides all EDI templates as C# files, allowing developers to combine templates and build their projects. For more information on EDI templates, go to the EDI Templates section.

Both the trial and the paid versions can use the EDI templates that can be downloaded from EdiNation EDI Formats.

 

Create a New Project

Let's create a new project that will be reading/parsing X12 files.

  1. Create a new Console Project in Visual Studio.
  2. Install EdiFabric from NuGet

    PM> NuGet\Install-Package EdiFabric 

    or by following the steps in the Install EDI Tools for .NET article.

  3. Open Program.cs and paste the following code, overwriting the existing one:

    using EdiFabric.Core.Model.Edi;
    using EdiFabric.Framework.Readers;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    
    namespace ConsoleApp
    {
        class Program
        {
            static void Main(string[] args)
            {
    var x12File = File.OpenRead(@"{Path to X12 file}");

    EdiFabric.SerialKey.Set("{Serial key}"); List<IEdiItem> ediItems; using (var reader = new X12Reader(x12File, "{X12 Templates}", new X12ReaderSettings {ContinueOnError = true })) { ediItems = reader.ReadToEnd().ToList(); } } } }
  4. Get your serial key and change {Serial key} to it.
  5. Change {Path to X12 file} to point to the EDI file you want to read.
  6. Install the EDI templates by following the steps below.

 

Install and reference the EDI templates

There are three ways to install the EDI templates - from the trial, from EdiNation, and from the C# files included in the paid version. Let's go over each option.

 

Install the trial EDI templates

  1. Install the template package for the EDI standard you need from NuGet. For example, if you want to translate from X12/HIPAA files, install EdiFabric.Templates.X12, if you want to translate from EDIFACT/EANCOM files, install EdiFabric.Templates.Edifact.

    PM> NuGet\Install-Package EdiFabric.Templates.X12 
  2. Once you install EdiFabric.Templates.X12, your project references should look like this:

  3. Change {X12 Templates} to EdiFabric.Templates.X12

    using (var reader = new X12Reader(x12File, "EdiFabric.Templates.X12"

 

Install the EDI templates from the C# files included in the paid version

  1. Create a new Class Library project.
  2. Remove the default Class1.cs.
  3. Install EdiFabric from NuGet

    PM> NuGet\Install-Package EdiFabric 

    or by following the steps in the Install EDI Tools for .NET article.

  4. For .NET Framework only: Add references to System.Runtime.Serialization and System.Xml.Serialization.

  5. Navigate to the EdiFabric.Sdk\EDI Templates folder you downloaded. Add the EDI templates (C# files) you need to use (in this example, it is - transaction: 850, version: 4010, standard: X12), together with all the files in the Common folder to the class library project as existing files:

    The common files are the five files ending with _Codes.cs _ComplexElementInterfaces.cs _ComplexElements.cs _SegmentInterfaces.cs _Segments.cs

  6. Add a project reference in the Console Project to the Class Library project.

    Your project references should look like this:

  7. Change {X12 Templates} to ClassLibrary1

    using (var reader = new X12Reader(x12File, "ClassLibrary1"

 

Install the EDI templates from EdiNation

Only available for NET6+ projects

  1. Navigate to EdiNation EDI Formats.
  2. Select the EDI standard and version you want to download, e.g., for X12 5010

    edination-templates.png
  3. Click to download the EDI templates:

    edination-templates-download.png
  4. The templates will be downloaded as a DLL file named EdiNation.X12.ASC.005010.dll.
  5. Add a reference in the Console Project to EdiNation.X12.ASC.005010.dll.
  6. Your project references should look like this:

  7. Change {X12 Templates} to EdiNation.X12.ASC.005010

    using (var reader = new X12Reader(x12File, "EdiNation.X12.ASC.005010"

 

Good practices

 

When to use the different options for installing the templates

Install the trial templates from NuGet or the EDI templates from EdiNation only as part of your evaluation or when using the example solutions. The trial templates will still work with the paid version but are limited to the specific EDI versions listed in the Free code to master your EDI files article. The EdiNation DLLs combine all templates per version hence are very large and are only available as DLL files.

We recommend that you only install the templates as C# files in production. This allows you to include only the templates for the transactions you need, build modifications per partner, and install them as DLLs or local NuGet packages.

 

Loading EDI templates from multiple projects

When installing the templates as C# files, we recommend combining all EDI templates per the same version and/or the same partner into the same VS project. At runtime, you can load templates either implicitly as assemblies or explicitly as C# types. For more information on how to do that, go to the Parse EDI files article, matching EDI templates paragraph.

 

Share this:

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.