Jasinski Technical Wiki

Navigation

Home Page
Index
All Pages

Quick Search
»
Advanced Search »

Contributor Links

Create a new Page
Administration
File Management
Login/Logout
Your Profile

Other Wiki Sections

Software

PoweredBy

Page History: Database Seeding Framework - C#

Compare Page Revisions



« Older Revision - Back to Page History - Current Revision


Page Revision: Thu, Aug 02, 2018, 9:05 AM


public abstract class SeedBase
{
    public abstract void Execute();
}

public class SeedEngine
{
    public static void ApplyVersionedUpdates()
    {
        var asm = Assembly.GetExecutingAssembly();
        var seedVersions = asm.DefinedTypes.Where(a => a.BaseType == typeof(SeedBase)).OrderBy(a => a.Name);

        foreach (var seedVer in seedVersions)
        {
            var result = Activator.CreateInstance(seedVer) as SeedBase;

            if (result == null)
                continue;

            Debug.Print($"Running seed {seedVer.Name}");
            result.Execute(); 
        }

    }
        
}

ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.