Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consider more efficient pattern for seed data that will never change #14922

Open
Tracked by #22947
voroninp opened this issue Mar 5, 2019 · 22 comments
Open
Tracked by #22947

Consider more efficient pattern for seed data that will never change #14922

voroninp opened this issue Mar 5, 2019 · 22 comments

Comments

@voroninp
Copy link

voroninp commented Mar 5, 2019

I am a bit perplexed.

My first migration contains seeding data for the table Countries - 249 rows. This initialization data exists in InitMigration.Up step (Ok), in ModelSnapshot.BuildModel (Ok) and in InitMigration.BuildTargetModel (Ok?).

I added the second migration, and I see that countries data is again present in BuildTargetModel of this migration. Does this mean that model is recreated from scratch for every migration? What if my initial migration contained several thousands of rows for seeded data? Would source code of each subsequent migration have size of megabytes?

Here's the code for configuring Country:

sealed class CountryConfiguration : IEntityTypeConfiguration<Country>
{
    public void Configure(EntityTypeBuilder<Country> builder)
    {
        builder.ToTable("Country");

        builder.HasOne<WorldRegion>()
            .WithMany()
            .HasForeignKey(m => m.RegionId)
            .IsRequired(false)
            .OnDelete(DeleteBehavior.SetNull);

        builder.HasAlternateKey(m => m.Name);
        builder.HasAlternateKey(m => m.NumericCode);
        builder.HasAlternateKey(m => m.Alpha2Code);
        builder.HasAlternateKey(m => m.Alpha3Code);

        object[] countriesData = Geography.List.Countries().ToArray();
        builder.HasData(countriesData);
    }
}

And here is the code for getting countries seeding data:

namespace Geography

open System
open FSharp.Data
open System.Collections.Generic

module List =

    type Region = {Id: int; Name:string; NumericCode: string} 

    type Country = { 
        Id:int;
        RegionId: Nullable<int>;
        Name: string;
        NumericCode: string;
        Alpha2Code: string;
        Alpha3Code: string;
    }

    [<Literal>] let private ``countries csv file`` = "./countries.csv"

    type private CountriesProvider = CsvProvider<
        ``countries csv file``, 
        Schema = "name,alpha-2,alpha-3,country-code (string),iso_3166-2,region,sub-region,intermediate-region,region-code (string),sub-region-code,intermediate-region-code"
        >

    let private countriesFile() = CountriesProvider.Load(``countries csv file``)

    let Regions(): IEnumerable<Region> = 
        countriesFile().Rows 
        |> Seq.distinctBy (fun row -> row.``Region-code``)
        |> Seq.mapi (fun index row -> {Id = index+1; Name = row.Region; NumericCode = row.``Region-code``})
        |> Seq.filter (fun r -> not (String.IsNullOrWhiteSpace r.Name))

    let RegionsByCode() = 
        Regions()
        |> Seq.map (fun r -> (r.NumericCode, r))
        |> dict

    let Countries(): IEnumerable<Country> =
        let regionsByCode = RegionsByCode()

        countriesFile().Rows
        |> Seq.distinctBy (fun row -> row.``Country-code``)
        |> Seq.mapi (
            fun index row -> 
                let regionId = 
                    let exists, r = regionsByCode.TryGetValue row.``Region-code``
                    if exists 
                    then Nullable<int> r.Id 
                    else Unchecked.defaultof<Nullable<int>>

                {
                    Id = index+1;
                    RegionId = regionId;
                    Name = row.Name;
                    NumericCode = row.``Country-code``;
                    Alpha2Code = row.``Alpha-2``;
                    Alpha3Code = row.``Alpha-3``;
                })
    
    let CountriesByCode() = 
        Countries()
        |> Seq.map (fun c -> (c.NumericCode, c))
        |> dict

Country is a reference table, so no change mechanism besides migrations is planned. Am I abusing data seeding or is it somehow possible to avoid codebase bloating?

@bricelam
Copy link
Contributor

bricelam commented Mar 7, 2019

ModelSnapshot is a snapshot of the model from the last time you ran Add-Migration. It's used to get the diff the next time you call Add-Migration.

Migration.BuildTargetModel is a copy of the model for that migration. It's used when the steps in the Up method aren't enough. For example, we use it to rebuild indexes on SQL Server when a column type is narrowed from int to smallint. It's rarely used, but enables scenarios that would otherwise require the user to manually add additional steps to the Up method.

@voroninp
Copy link
Author

voroninp commented Mar 7, 2019

@bricelam any option to opt out for particular migration? Or what should I do with the seeding?

@bricelam
Copy link
Contributor

bricelam commented Mar 7, 2019

You can remove it if you know what you're doing. See this answer on Stack Overflow.

If your seed data never changes, you may want to consider just adding it to the Up method of a migration and not using EntityTypeBuilder.HasData().

@voroninp
Copy link
Author

voroninp commented Mar 8, 2019

@bricelam Well, even the list of countries changes from time to time. I also automatically generate lookup data for enums.

@bricelam
Copy link
Contributor

bricelam commented Mar 8, 2019

Have you considered putting the migrations and snapshot into their own assembly? This at least lets you cut down on deployment size.

@ajcvickers ajcvickers added the closed-no-further-action The issue is closed and no further action is planned. label Mar 8, 2019
@bricelam
Copy link
Contributor

bricelam commented Mar 8, 2019

Just to record some internal dialog:

We considered omitting HasData from Migration.BuildTargetModel, but then we realized this would break Remove-Migration.

@voroninp
Copy link
Author

voroninp commented Mar 9, 2019

@bricelam Isn't Up and ModelSnapshot enough?

@bricelam
Copy link
Contributor

bricelam commented Mar 9, 2019

No, not if your database is 2+ migrations behind.

@voroninp
Copy link
Author

voroninp commented Mar 10, 2019

@bricelam,

we realized this would break Remove-Migration.
not if your database is 2+ migrations behind.

How come? Removing migration is dropping the last one and bringing ModelSnapshot to the state it had before migration was added, isn't it? Shouldn't it then be quivalent to virtually applying all migrations in sequence just from scratch? It seems I am missing something here ...

@bricelam
Copy link
Contributor

bricelam commented Mar 11, 2019

In theory, we could apply the migration's Down operations (which in turn could also just be the inverse of the Up operations) to the model snapshot. In practice, we just take the model from the previous migration.

I too argued for a more sophisticated Migrations implementation at first, but ultimately, we decided to go with a simpler, more pragmatic approach. I concede that the more sophisticated version would probably have a lot more bugs.

@voroninp
Copy link
Author

@bricelam Btw, you offered to put migrations into different assembly. That's what I did from the very beginning. However, from your words I understood there is no need to deploy this assembly as it is needed only for applying migrations.

Then I have a question about SqlServerDbContextOptionsBuilder.MigrationAssembly method. Do I need to call it, if migrations are applied outside of the application, and I never call context.Database.Migrate();?

@bricelam
Copy link
Contributor

You need to set MigrationAssembly so the tools (dotnet ef, Script-Migration, Web Publish, etc.) work. It takes a string so your code never has to reference the migrations assembly and you can avoid deploying it.

@voroninp
Copy link
Author

@bricelam But if assembly is not referenced it is never copied to the output of a startup project. Do tools just search for the corresponding project of solution?

@bricelam
Copy link
Contributor

You’ll still need a project reference. The compiled assembly just won’t have an assembly reference.

@voroninp
Copy link
Author

@bricelam , it looks like deleting BuildTargetModel was a bad idea. After I add next migration and remove it I end up with an empty ModelSnapshot:

[DbContext(typeof(DeviceContext))]
partial class DeviceContextModelSnapshot : ModelSnapshot
{
    protected override void BuildModel(ModelBuilder modelBuilder)
    {
        #pragma warning disable 612, 618
        modelBuilder
            .HasAnnotation("ProductVersion", "2.2.2-servicing-10034");
         #pragma warning restore 612, 618
    }
}

@voroninp
Copy link
Author

And just to let you feel the pain =)

This code is repeated for every migration since the very first time when Country configuration called HasData:

            modelBuilder.Entity("Connect.Device.BusinessModel.Entities.Country", b =>
                {
                    b.Property<int>("Id")
                        .ValueGeneratedOnAdd()
                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);

                    b.Property<string>("Alpha2Code")
                        .IsRequired()
                        .HasMaxLength(2);

                    b.Property<string>("Alpha3Code")
                        .IsRequired()
                        .HasMaxLength(3);

                    b.Property<string>("Name")
                        .IsRequired()
                        .HasMaxLength(255);

                    b.Property<string>("NumericCode")
                        .IsRequired()
                        .HasMaxLength(3);

                    b.Property<int?>("RegionId");

                    b.HasKey("Id");

                    b.HasAlternateKey("Alpha2Code");

                    b.HasAlternateKey("Alpha3Code");

                    b.HasAlternateKey("Name");

                    b.HasAlternateKey("NumericCode");

                    b.HasIndex("RegionId");

                    b.ToTable("Country");

                    b.HasData(
                        new
                        {
                            Id = 1,
                            Alpha2Code = "AF",
                            Alpha3Code = "AFG",
                            Name = "Afghanistan",
                            NumericCode = "004",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 2,
                            Alpha2Code = "AX",
                            Alpha3Code = "ALA",
                            Name = "Åland Islands",
                            NumericCode = "248",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 3,
                            Alpha2Code = "AL",
                            Alpha3Code = "ALB",
                            Name = "Albania",
                            NumericCode = "008",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 4,
                            Alpha2Code = "DZ",
                            Alpha3Code = "DZA",
                            Name = "Algeria",
                            NumericCode = "012",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 5,
                            Alpha2Code = "AS",
                            Alpha3Code = "ASM",
                            Name = "American Samoa",
                            NumericCode = "016",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 6,
                            Alpha2Code = "AD",
                            Alpha3Code = "AND",
                            Name = "Andorra",
                            NumericCode = "020",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 7,
                            Alpha2Code = "AO",
                            Alpha3Code = "AGO",
                            Name = "Angola",
                            NumericCode = "024",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 8,
                            Alpha2Code = "AI",
                            Alpha3Code = "AIA",
                            Name = "Anguilla",
                            NumericCode = "660",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 9,
                            Alpha2Code = "AQ",
                            Alpha3Code = "ATA",
                            Name = "Antarctica",
                            NumericCode = "010"
                        },
                        new
                        {
                            Id = 10,
                            Alpha2Code = "AG",
                            Alpha3Code = "ATG",
                            Name = "Antigua and Barbuda",
                            NumericCode = "028",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 11,
                            Alpha2Code = "AR",
                            Alpha3Code = "ARG",
                            Name = "Argentina",
                            NumericCode = "032",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 12,
                            Alpha2Code = "AM",
                            Alpha3Code = "ARM",
                            Name = "Armenia",
                            NumericCode = "051",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 13,
                            Alpha2Code = "AW",
                            Alpha3Code = "ABW",
                            Name = "Aruba",
                            NumericCode = "533",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 14,
                            Alpha2Code = "AU",
                            Alpha3Code = "AUS",
                            Name = "Australia",
                            NumericCode = "036",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 15,
                            Alpha2Code = "AT",
                            Alpha3Code = "AUT",
                            Name = "Austria",
                            NumericCode = "040",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 16,
                            Alpha2Code = "AZ",
                            Alpha3Code = "AZE",
                            Name = "Azerbaijan",
                            NumericCode = "031",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 17,
                            Alpha2Code = "BS",
                            Alpha3Code = "BHS",
                            Name = "Bahamas",
                            NumericCode = "044",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 18,
                            Alpha2Code = "BH",
                            Alpha3Code = "BHR",
                            Name = "Bahrain",
                            NumericCode = "048",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 19,
                            Alpha2Code = "BD",
                            Alpha3Code = "BGD",
                            Name = "Bangladesh",
                            NumericCode = "050",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 20,
                            Alpha2Code = "BB",
                            Alpha3Code = "BRB",
                            Name = "Barbados",
                            NumericCode = "052",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 21,
                            Alpha2Code = "BY",
                            Alpha3Code = "BLR",
                            Name = "Belarus",
                            NumericCode = "112",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 22,
                            Alpha2Code = "BE",
                            Alpha3Code = "BEL",
                            Name = "Belgium",
                            NumericCode = "056",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 23,
                            Alpha2Code = "BZ",
                            Alpha3Code = "BLZ",
                            Name = "Belize",
                            NumericCode = "084",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 24,
                            Alpha2Code = "BJ",
                            Alpha3Code = "BEN",
                            Name = "Benin",
                            NumericCode = "204",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 25,
                            Alpha2Code = "BM",
                            Alpha3Code = "BMU",
                            Name = "Bermuda",
                            NumericCode = "060",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 26,
                            Alpha2Code = "BT",
                            Alpha3Code = "BTN",
                            Name = "Bhutan",
                            NumericCode = "064",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 27,
                            Alpha2Code = "BO",
                            Alpha3Code = "BOL",
                            Name = "Bolivia (Plurinational State of)",
                            NumericCode = "068",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 28,
                            Alpha2Code = "BQ",
                            Alpha3Code = "BES",
                            Name = "Bonaire, Sint Eustatius and Saba",
                            NumericCode = "535",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 29,
                            Alpha2Code = "BA",
                            Alpha3Code = "BIH",
                            Name = "Bosnia and Herzegovina",
                            NumericCode = "070",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 30,
                            Alpha2Code = "BW",
                            Alpha3Code = "BWA",
                            Name = "Botswana",
                            NumericCode = "072",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 31,
                            Alpha2Code = "BV",
                            Alpha3Code = "BVT",
                            Name = "Bouvet Island",
                            NumericCode = "074",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 32,
                            Alpha2Code = "BR",
                            Alpha3Code = "BRA",
                            Name = "Brazil",
                            NumericCode = "076",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 33,
                            Alpha2Code = "IO",
                            Alpha3Code = "IOT",
                            Name = "British Indian Ocean Territory",
                            NumericCode = "086",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 34,
                            Alpha2Code = "BN",
                            Alpha3Code = "BRN",
                            Name = "Brunei Darussalam",
                            NumericCode = "096",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 35,
                            Alpha2Code = "BG",
                            Alpha3Code = "BGR",
                            Name = "Bulgaria",
                            NumericCode = "100",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 36,
                            Alpha2Code = "BF",
                            Alpha3Code = "BFA",
                            Name = "Burkina Faso",
                            NumericCode = "854",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 37,
                            Alpha2Code = "BI",
                            Alpha3Code = "BDI",
                            Name = "Burundi",
                            NumericCode = "108",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 38,
                            Alpha2Code = "CV",
                            Alpha3Code = "CPV",
                            Name = "Cabo Verde",
                            NumericCode = "132",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 39,
                            Alpha2Code = "KH",
                            Alpha3Code = "KHM",
                            Name = "Cambodia",
                            NumericCode = "116",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 40,
                            Alpha2Code = "CM",
                            Alpha3Code = "CMR",
                            Name = "Cameroon",
                            NumericCode = "120",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 41,
                            Alpha2Code = "CA",
                            Alpha3Code = "CAN",
                            Name = "Canada",
                            NumericCode = "124",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 42,
                            Alpha2Code = "KY",
                            Alpha3Code = "CYM",
                            Name = "Cayman Islands",
                            NumericCode = "136",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 43,
                            Alpha2Code = "CF",
                            Alpha3Code = "CAF",
                            Name = "Central African Republic",
                            NumericCode = "140",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 44,
                            Alpha2Code = "TD",
                            Alpha3Code = "TCD",
                            Name = "Chad",
                            NumericCode = "148",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 45,
                            Alpha2Code = "CL",
                            Alpha3Code = "CHL",
                            Name = "Chile",
                            NumericCode = "152",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 46,
                            Alpha2Code = "CN",
                            Alpha3Code = "CHN",
                            Name = "China",
                            NumericCode = "156",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 47,
                            Alpha2Code = "CX",
                            Alpha3Code = "CXR",
                            Name = "Christmas Island",
                            NumericCode = "162",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 48,
                            Alpha2Code = "CC",
                            Alpha3Code = "CCK",
                            Name = "Cocos (Keeling) Islands",
                            NumericCode = "166",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 49,
                            Alpha2Code = "CO",
                            Alpha3Code = "COL",
                            Name = "Colombia",
                            NumericCode = "170",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 50,
                            Alpha2Code = "KM",
                            Alpha3Code = "COM",
                            Name = "Comoros",
                            NumericCode = "174",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 51,
                            Alpha2Code = "CG",
                            Alpha3Code = "COG",
                            Name = "Congo",
                            NumericCode = "178",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 52,
                            Alpha2Code = "CD",
                            Alpha3Code = "COD",
                            Name = "Congo (Democratic Republic of the)",
                            NumericCode = "180",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 53,
                            Alpha2Code = "CK",
                            Alpha3Code = "COK",
                            Name = "Cook Islands",
                            NumericCode = "184",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 54,
                            Alpha2Code = "CR",
                            Alpha3Code = "CRI",
                            Name = "Costa Rica",
                            NumericCode = "188",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 55,
                            Alpha2Code = "CI",
                            Alpha3Code = "CIV",
                            Name = "Côte d'Ivoire",
                            NumericCode = "384",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 56,
                            Alpha2Code = "HR",
                            Alpha3Code = "HRV",
                            Name = "Croatia",
                            NumericCode = "191",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 57,
                            Alpha2Code = "CU",
                            Alpha3Code = "CUB",
                            Name = "Cuba",
                            NumericCode = "192",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 58,
                            Alpha2Code = "CW",
                            Alpha3Code = "CUW",
                            Name = "Curaçao",
                            NumericCode = "531",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 59,
                            Alpha2Code = "CY",
                            Alpha3Code = "CYP",
                            Name = "Cyprus",
                            NumericCode = "196",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 60,
                            Alpha2Code = "CZ",
                            Alpha3Code = "CZE",
                            Name = "Czechia",
                            NumericCode = "203",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 61,
                            Alpha2Code = "DK",
                            Alpha3Code = "DNK",
                            Name = "Denmark",
                            NumericCode = "208",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 62,
                            Alpha2Code = "DJ",
                            Alpha3Code = "DJI",
                            Name = "Djibouti",
                            NumericCode = "262",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 63,
                            Alpha2Code = "DM",
                            Alpha3Code = "DMA",
                            Name = "Dominica",
                            NumericCode = "212",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 64,
                            Alpha2Code = "DO",
                            Alpha3Code = "DOM",
                            Name = "Dominican Republic",
                            NumericCode = "214",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 65,
                            Alpha2Code = "EC",
                            Alpha3Code = "ECU",
                            Name = "Ecuador",
                            NumericCode = "218",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 66,
                            Alpha2Code = "EG",
                            Alpha3Code = "EGY",
                            Name = "Egypt",
                            NumericCode = "818",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 67,
                            Alpha2Code = "SV",
                            Alpha3Code = "SLV",
                            Name = "El Salvador",
                            NumericCode = "222",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 68,
                            Alpha2Code = "GQ",
                            Alpha3Code = "GNQ",
                            Name = "Equatorial Guinea",
                            NumericCode = "226",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 69,
                            Alpha2Code = "ER",
                            Alpha3Code = "ERI",
                            Name = "Eritrea",
                            NumericCode = "232",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 70,
                            Alpha2Code = "EE",
                            Alpha3Code = "EST",
                            Name = "Estonia",
                            NumericCode = "233",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 71,
                            Alpha2Code = "SZ",
                            Alpha3Code = "SWZ",
                            Name = "Eswatini",
                            NumericCode = "748",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 72,
                            Alpha2Code = "ET",
                            Alpha3Code = "ETH",
                            Name = "Ethiopia",
                            NumericCode = "231",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 73,
                            Alpha2Code = "FK",
                            Alpha3Code = "FLK",
                            Name = "Falkland Islands (Malvinas)",
                            NumericCode = "238",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 74,
                            Alpha2Code = "FO",
                            Alpha3Code = "FRO",
                            Name = "Faroe Islands",
                            NumericCode = "234",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 75,
                            Alpha2Code = "FJ",
                            Alpha3Code = "FJI",
                            Name = "Fiji",
                            NumericCode = "242",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 76,
                            Alpha2Code = "FI",
                            Alpha3Code = "FIN",
                            Name = "Finland",
                            NumericCode = "246",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 77,
                            Alpha2Code = "FR",
                            Alpha3Code = "FRA",
                            Name = "France",
                            NumericCode = "250",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 78,
                            Alpha2Code = "GF",
                            Alpha3Code = "GUF",
                            Name = "French Guiana",
                            NumericCode = "254",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 79,
                            Alpha2Code = "PF",
                            Alpha3Code = "PYF",
                            Name = "French Polynesia",
                            NumericCode = "258",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 80,
                            Alpha2Code = "TF",
                            Alpha3Code = "ATF",
                            Name = "French Southern Territories",
                            NumericCode = "260",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 81,
                            Alpha2Code = "GA",
                            Alpha3Code = "GAB",
                            Name = "Gabon",
                            NumericCode = "266",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 82,
                            Alpha2Code = "GM",
                            Alpha3Code = "GMB",
                            Name = "Gambia",
                            NumericCode = "270",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 83,
                            Alpha2Code = "GE",
                            Alpha3Code = "GEO",
                            Name = "Georgia",
                            NumericCode = "268",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 84,
                            Alpha2Code = "DE",
                            Alpha3Code = "DEU",
                            Name = "Germany",
                            NumericCode = "276",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 85,
                            Alpha2Code = "GH",
                            Alpha3Code = "GHA",
                            Name = "Ghana",
                            NumericCode = "288",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 86,
                            Alpha2Code = "GI",
                            Alpha3Code = "GIB",
                            Name = "Gibraltar",
                            NumericCode = "292",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 87,
                            Alpha2Code = "GR",
                            Alpha3Code = "GRC",
                            Name = "Greece",
                            NumericCode = "300",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 88,
                            Alpha2Code = "GL",
                            Alpha3Code = "GRL",
                            Name = "Greenland",
                            NumericCode = "304",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 89,
                            Alpha2Code = "GD",
                            Alpha3Code = "GRD",
                            Name = "Grenada",
                            NumericCode = "308",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 90,
                            Alpha2Code = "GP",
                            Alpha3Code = "GLP",
                            Name = "Guadeloupe",
                            NumericCode = "312",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 91,
                            Alpha2Code = "GU",
                            Alpha3Code = "GUM",
                            Name = "Guam",
                            NumericCode = "316",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 92,
                            Alpha2Code = "GT",
                            Alpha3Code = "GTM",
                            Name = "Guatemala",
                            NumericCode = "320",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 93,
                            Alpha2Code = "GG",
                            Alpha3Code = "GGY",
                            Name = "Guernsey",
                            NumericCode = "831",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 94,
                            Alpha2Code = "GN",
                            Alpha3Code = "GIN",
                            Name = "Guinea",
                            NumericCode = "324",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 95,
                            Alpha2Code = "GW",
                            Alpha3Code = "GNB",
                            Name = "Guinea-Bissau",
                            NumericCode = "624",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 96,
                            Alpha2Code = "GY",
                            Alpha3Code = "GUY",
                            Name = "Guyana",
                            NumericCode = "328",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 97,
                            Alpha2Code = "HT",
                            Alpha3Code = "HTI",
                            Name = "Haiti",
                            NumericCode = "332",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 98,
                            Alpha2Code = "HM",
                            Alpha3Code = "HMD",
                            Name = "Heard Island and McDonald Islands",
                            NumericCode = "334",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 99,
                            Alpha2Code = "VA",
                            Alpha3Code = "VAT",
                            Name = "Holy See",
                            NumericCode = "336",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 100,
                            Alpha2Code = "HN",
                            Alpha3Code = "HND",
                            Name = "Honduras",
                            NumericCode = "340",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 101,
                            Alpha2Code = "HK",
                            Alpha3Code = "HKG",
                            Name = "Hong Kong",
                            NumericCode = "344",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 102,
                            Alpha2Code = "HU",
                            Alpha3Code = "HUN",
                            Name = "Hungary",
                            NumericCode = "348",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 103,
                            Alpha2Code = "IS",
                            Alpha3Code = "ISL",
                            Name = "Iceland",
                            NumericCode = "352",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 104,
                            Alpha2Code = "IN",
                            Alpha3Code = "IND",
                            Name = "India",
                            NumericCode = "356",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 105,
                            Alpha2Code = "ID",
                            Alpha3Code = "IDN",
                            Name = "Indonesia",
                            NumericCode = "360",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 106,
                            Alpha2Code = "IR",
                            Alpha3Code = "IRN",
                            Name = "Iran (Islamic Republic of)",
                            NumericCode = "364",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 107,
                            Alpha2Code = "IQ",
                            Alpha3Code = "IRQ",
                            Name = "Iraq",
                            NumericCode = "368",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 108,
                            Alpha2Code = "IE",
                            Alpha3Code = "IRL",
                            Name = "Ireland",
                            NumericCode = "372",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 109,
                            Alpha2Code = "IM",
                            Alpha3Code = "IMN",
                            Name = "Isle of Man",
                            NumericCode = "833",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 110,
                            Alpha2Code = "IL",
                            Alpha3Code = "ISR",
                            Name = "Israel",
                            NumericCode = "376",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 111,
                            Alpha2Code = "IT",
                            Alpha3Code = "ITA",
                            Name = "Italy",
                            NumericCode = "380",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 112,
                            Alpha2Code = "JM",
                            Alpha3Code = "JAM",
                            Name = "Jamaica",
                            NumericCode = "388",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 113,
                            Alpha2Code = "JP",
                            Alpha3Code = "JPN",
                            Name = "Japan",
                            NumericCode = "392",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 114,
                            Alpha2Code = "JE",
                            Alpha3Code = "JEY",
                            Name = "Jersey",
                            NumericCode = "832",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 115,
                            Alpha2Code = "JO",
                            Alpha3Code = "JOR",
                            Name = "Jordan",
                            NumericCode = "400",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 116,
                            Alpha2Code = "KZ",
                            Alpha3Code = "KAZ",
                            Name = "Kazakhstan",
                            NumericCode = "398",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 117,
                            Alpha2Code = "KE",
                            Alpha3Code = "KEN",
                            Name = "Kenya",
                            NumericCode = "404",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 118,
                            Alpha2Code = "KI",
                            Alpha3Code = "KIR",
                            Name = "Kiribati",
                            NumericCode = "296",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 119,
                            Alpha2Code = "KP",
                            Alpha3Code = "PRK",
                            Name = "Korea (Democratic People's Republic of)",
                            NumericCode = "408",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 120,
                            Alpha2Code = "KR",
                            Alpha3Code = "KOR",
                            Name = "Korea (Republic of)",
                            NumericCode = "410",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 121,
                            Alpha2Code = "KW",
                            Alpha3Code = "KWT",
                            Name = "Kuwait",
                            NumericCode = "414",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 122,
                            Alpha2Code = "KG",
                            Alpha3Code = "KGZ",
                            Name = "Kyrgyzstan",
                            NumericCode = "417",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 123,
                            Alpha2Code = "LA",
                            Alpha3Code = "LAO",
                            Name = "Lao People's Democratic Republic",
                            NumericCode = "418",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 124,
                            Alpha2Code = "LV",
                            Alpha3Code = "LVA",
                            Name = "Latvia",
                            NumericCode = "428",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 125,
                            Alpha2Code = "LB",
                            Alpha3Code = "LBN",
                            Name = "Lebanon",
                            NumericCode = "422",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 126,
                            Alpha2Code = "LS",
                            Alpha3Code = "LSO",
                            Name = "Lesotho",
                            NumericCode = "426",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 127,
                            Alpha2Code = "LR",
                            Alpha3Code = "LBR",
                            Name = "Liberia",
                            NumericCode = "430",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 128,
                            Alpha2Code = "LY",
                            Alpha3Code = "LBY",
                            Name = "Libya",
                            NumericCode = "434",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 129,
                            Alpha2Code = "LI",
                            Alpha3Code = "LIE",
                            Name = "Liechtenstein",
                            NumericCode = "438",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 130,
                            Alpha2Code = "LT",
                            Alpha3Code = "LTU",
                            Name = "Lithuania",
                            NumericCode = "440",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 131,
                            Alpha2Code = "LU",
                            Alpha3Code = "LUX",
                            Name = "Luxembourg",
                            NumericCode = "442",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 132,
                            Alpha2Code = "MO",
                            Alpha3Code = "MAC",
                            Name = "Macao",
                            NumericCode = "446",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 133,
                            Alpha2Code = "MK",
                            Alpha3Code = "MKD",
                            Name = "Macedonia (the former Yugoslav Republic of)",
                            NumericCode = "807",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 134,
                            Alpha2Code = "MG",
                            Alpha3Code = "MDG",
                            Name = "Madagascar",
                            NumericCode = "450",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 135,
                            Alpha2Code = "MW",
                            Alpha3Code = "MWI",
                            Name = "Malawi",
                            NumericCode = "454",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 136,
                            Alpha2Code = "MY",
                            Alpha3Code = "MYS",
                            Name = "Malaysia",
                            NumericCode = "458",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 137,
                            Alpha2Code = "MV",
                            Alpha3Code = "MDV",
                            Name = "Maldives",
                            NumericCode = "462",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 138,
                            Alpha2Code = "ML",
                            Alpha3Code = "MLI",
                            Name = "Mali",
                            NumericCode = "466",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 139,
                            Alpha2Code = "MT",
                            Alpha3Code = "MLT",
                            Name = "Malta",
                            NumericCode = "470",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 140,
                            Alpha2Code = "MH",
                            Alpha3Code = "MHL",
                            Name = "Marshall Islands",
                            NumericCode = "584",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 141,
                            Alpha2Code = "MQ",
                            Alpha3Code = "MTQ",
                            Name = "Martinique",
                            NumericCode = "474",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 142,
                            Alpha2Code = "MR",
                            Alpha3Code = "MRT",
                            Name = "Mauritania",
                            NumericCode = "478",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 143,
                            Alpha2Code = "MU",
                            Alpha3Code = "MUS",
                            Name = "Mauritius",
                            NumericCode = "480",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 144,
                            Alpha2Code = "YT",
                            Alpha3Code = "MYT",
                            Name = "Mayotte",
                            NumericCode = "175",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 145,
                            Alpha2Code = "MX",
                            Alpha3Code = "MEX",
                            Name = "Mexico",
                            NumericCode = "484",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 146,
                            Alpha2Code = "FM",
                            Alpha3Code = "FSM",
                            Name = "Micronesia (Federated States of)",
                            NumericCode = "583",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 147,
                            Alpha2Code = "MD",
                            Alpha3Code = "MDA",
                            Name = "Moldova (Republic of)",
                            NumericCode = "498",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 148,
                            Alpha2Code = "MC",
                            Alpha3Code = "MCO",
                            Name = "Monaco",
                            NumericCode = "492",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 149,
                            Alpha2Code = "MN",
                            Alpha3Code = "MNG",
                            Name = "Mongolia",
                            NumericCode = "496",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 150,
                            Alpha2Code = "ME",
                            Alpha3Code = "MNE",
                            Name = "Montenegro",
                            NumericCode = "499",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 151,
                            Alpha2Code = "MS",
                            Alpha3Code = "MSR",
                            Name = "Montserrat",
                            NumericCode = "500",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 152,
                            Alpha2Code = "MA",
                            Alpha3Code = "MAR",
                            Name = "Morocco",
                            NumericCode = "504",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 153,
                            Alpha2Code = "MZ",
                            Alpha3Code = "MOZ",
                            Name = "Mozambique",
                            NumericCode = "508",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 154,
                            Alpha2Code = "MM",
                            Alpha3Code = "MMR",
                            Name = "Myanmar",
                            NumericCode = "104",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 155,
                            Alpha2Code = "NA",
                            Alpha3Code = "NAM",
                            Name = "Namibia",
                            NumericCode = "516",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 156,
                            Alpha2Code = "NR",
                            Alpha3Code = "NRU",
                            Name = "Nauru",
                            NumericCode = "520",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 157,
                            Alpha2Code = "NP",
                            Alpha3Code = "NPL",
                            Name = "Nepal",
                            NumericCode = "524",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 158,
                            Alpha2Code = "NL",
                            Alpha3Code = "NLD",
                            Name = "Netherlands",
                            NumericCode = "528",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 159,
                            Alpha2Code = "NC",
                            Alpha3Code = "NCL",
                            Name = "New Caledonia",
                            NumericCode = "540",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 160,
                            Alpha2Code = "NZ",
                            Alpha3Code = "NZL",
                            Name = "New Zealand",
                            NumericCode = "554",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 161,
                            Alpha2Code = "NI",
                            Alpha3Code = "NIC",
                            Name = "Nicaragua",
                            NumericCode = "558",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 162,
                            Alpha2Code = "NE",
                            Alpha3Code = "NER",
                            Name = "Niger",
                            NumericCode = "562",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 163,
                            Alpha2Code = "NG",
                            Alpha3Code = "NGA",
                            Name = "Nigeria",
                            NumericCode = "566",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 164,
                            Alpha2Code = "NU",
                            Alpha3Code = "NIU",
                            Name = "Niue",
                            NumericCode = "570",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 165,
                            Alpha2Code = "NF",
                            Alpha3Code = "NFK",
                            Name = "Norfolk Island",
                            NumericCode = "574",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 166,
                            Alpha2Code = "MP",
                            Alpha3Code = "MNP",
                            Name = "Northern Mariana Islands",
                            NumericCode = "580",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 167,
                            Alpha2Code = "NO",
                            Alpha3Code = "NOR",
                            Name = "Norway",
                            NumericCode = "578",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 168,
                            Alpha2Code = "OM",
                            Alpha3Code = "OMN",
                            Name = "Oman",
                            NumericCode = "512",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 169,
                            Alpha2Code = "PK",
                            Alpha3Code = "PAK",
                            Name = "Pakistan",
                            NumericCode = "586",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 170,
                            Alpha2Code = "PW",
                            Alpha3Code = "PLW",
                            Name = "Palau",
                            NumericCode = "585",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 171,
                            Alpha2Code = "PS",
                            Alpha3Code = "PSE",
                            Name = "Palestine, State of",
                            NumericCode = "275",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 172,
                            Alpha2Code = "PA",
                            Alpha3Code = "PAN",
                            Name = "Panama",
                            NumericCode = "591",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 173,
                            Alpha2Code = "PG",
                            Alpha3Code = "PNG",
                            Name = "Papua New Guinea",
                            NumericCode = "598",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 174,
                            Alpha2Code = "PY",
                            Alpha3Code = "PRY",
                            Name = "Paraguay",
                            NumericCode = "600",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 175,
                            Alpha2Code = "PE",
                            Alpha3Code = "PER",
                            Name = "Peru",
                            NumericCode = "604",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 176,
                            Alpha2Code = "PH",
                            Alpha3Code = "PHL",
                            Name = "Philippines",
                            NumericCode = "608",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 177,
                            Alpha2Code = "PN",
                            Alpha3Code = "PCN",
                            Name = "Pitcairn",
                            NumericCode = "612",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 178,
                            Alpha2Code = "PL",
                            Alpha3Code = "POL",
                            Name = "Poland",
                            NumericCode = "616",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 179,
                            Alpha2Code = "PT",
                            Alpha3Code = "PRT",
                            Name = "Portugal",
                            NumericCode = "620",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 180,
                            Alpha2Code = "PR",
                            Alpha3Code = "PRI",
                            Name = "Puerto Rico",
                            NumericCode = "630",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 181,
                            Alpha2Code = "QA",
                            Alpha3Code = "QAT",
                            Name = "Qatar",
                            NumericCode = "634",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 182,
                            Alpha2Code = "RE",
                            Alpha3Code = "REU",
                            Name = "Réunion",
                            NumericCode = "638",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 183,
                            Alpha2Code = "RO",
                            Alpha3Code = "ROU",
                            Name = "Romania",
                            NumericCode = "642",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 184,
                            Alpha2Code = "RU",
                            Alpha3Code = "RUS",
                            Name = "Russian Federation",
                            NumericCode = "643",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 185,
                            Alpha2Code = "RW",
                            Alpha3Code = "RWA",
                            Name = "Rwanda",
                            NumericCode = "646",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 186,
                            Alpha2Code = "BL",
                            Alpha3Code = "BLM",
                            Name = "Saint Barthélemy",
                            NumericCode = "652",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 187,
                            Alpha2Code = "SH",
                            Alpha3Code = "SHN",
                            Name = "Saint Helena, Ascension and Tristan da Cunha",
                            NumericCode = "654",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 188,
                            Alpha2Code = "KN",
                            Alpha3Code = "KNA",
                            Name = "Saint Kitts and Nevis",
                            NumericCode = "659",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 189,
                            Alpha2Code = "LC",
                            Alpha3Code = "LCA",
                            Name = "Saint Lucia",
                            NumericCode = "662",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 190,
                            Alpha2Code = "MF",
                            Alpha3Code = "MAF",
                            Name = "Saint Martin (French part)",
                            NumericCode = "663",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 191,
                            Alpha2Code = "PM",
                            Alpha3Code = "SPM",
                            Name = "Saint Pierre and Miquelon",
                            NumericCode = "666",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 192,
                            Alpha2Code = "VC",
                            Alpha3Code = "VCT",
                            Name = "Saint Vincent and the Grenadines",
                            NumericCode = "670",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 193,
                            Alpha2Code = "WS",
                            Alpha3Code = "WSM",
                            Name = "Samoa",
                            NumericCode = "882",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 194,
                            Alpha2Code = "SM",
                            Alpha3Code = "SMR",
                            Name = "San Marino",
                            NumericCode = "674",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 195,
                            Alpha2Code = "ST",
                            Alpha3Code = "STP",
                            Name = "Sao Tome and Principe",
                            NumericCode = "678",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 196,
                            Alpha2Code = "SA",
                            Alpha3Code = "SAU",
                            Name = "Saudi Arabia",
                            NumericCode = "682",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 197,
                            Alpha2Code = "SN",
                            Alpha3Code = "SEN",
                            Name = "Senegal",
                            NumericCode = "686",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 198,
                            Alpha2Code = "RS",
                            Alpha3Code = "SRB",
                            Name = "Serbia",
                            NumericCode = "688",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 199,
                            Alpha2Code = "SC",
                            Alpha3Code = "SYC",
                            Name = "Seychelles",
                            NumericCode = "690",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 200,
                            Alpha2Code = "SL",
                            Alpha3Code = "SLE",
                            Name = "Sierra Leone",
                            NumericCode = "694",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 201,
                            Alpha2Code = "SG",
                            Alpha3Code = "SGP",
                            Name = "Singapore",
                            NumericCode = "702",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 202,
                            Alpha2Code = "SX",
                            Alpha3Code = "SXM",
                            Name = "Sint Maarten (Dutch part)",
                            NumericCode = "534",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 203,
                            Alpha2Code = "SK",
                            Alpha3Code = "SVK",
                            Name = "Slovakia",
                            NumericCode = "703",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 204,
                            Alpha2Code = "SI",
                            Alpha3Code = "SVN",
                            Name = "Slovenia",
                            NumericCode = "705",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 205,
                            Alpha2Code = "SB",
                            Alpha3Code = "SLB",
                            Name = "Solomon Islands",
                            NumericCode = "090",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 206,
                            Alpha2Code = "SO",
                            Alpha3Code = "SOM",
                            Name = "Somalia",
                            NumericCode = "706",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 207,
                            Alpha2Code = "ZA",
                            Alpha3Code = "ZAF",
                            Name = "South Africa",
                            NumericCode = "710",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 208,
                            Alpha2Code = "GS",
                            Alpha3Code = "SGS",
                            Name = "South Georgia and the South Sandwich Islands",
                            NumericCode = "239",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 209,
                            Alpha2Code = "SS",
                            Alpha3Code = "SSD",
                            Name = "South Sudan",
                            NumericCode = "728",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 210,
                            Alpha2Code = "ES",
                            Alpha3Code = "ESP",
                            Name = "Spain",
                            NumericCode = "724",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 211,
                            Alpha2Code = "LK",
                            Alpha3Code = "LKA",
                            Name = "Sri Lanka",
                            NumericCode = "144",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 212,
                            Alpha2Code = "SD",
                            Alpha3Code = "SDN",
                            Name = "Sudan",
                            NumericCode = "729",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 213,
                            Alpha2Code = "SR",
                            Alpha3Code = "SUR",
                            Name = "Suriname",
                            NumericCode = "740",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 214,
                            Alpha2Code = "SJ",
                            Alpha3Code = "SJM",
                            Name = "Svalbard and Jan Mayen",
                            NumericCode = "744",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 215,
                            Alpha2Code = "SE",
                            Alpha3Code = "SWE",
                            Name = "Sweden",
                            NumericCode = "752",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 216,
                            Alpha2Code = "CH",
                            Alpha3Code = "CHE",
                            Name = "Switzerland",
                            NumericCode = "756",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 217,
                            Alpha2Code = "SY",
                            Alpha3Code = "SYR",
                            Name = "Syrian Arab Republic",
                            NumericCode = "760",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 218,
                            Alpha2Code = "TW",
                            Alpha3Code = "TWN",
                            Name = "Taiwan, Province of China",
                            NumericCode = "158",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 219,
                            Alpha2Code = "TJ",
                            Alpha3Code = "TJK",
                            Name = "Tajikistan",
                            NumericCode = "762",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 220,
                            Alpha2Code = "TZ",
                            Alpha3Code = "TZA",
                            Name = "Tanzania, United Republic of",
                            NumericCode = "834",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 221,
                            Alpha2Code = "TH",
                            Alpha3Code = "THA",
                            Name = "Thailand",
                            NumericCode = "764",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 222,
                            Alpha2Code = "TL",
                            Alpha3Code = "TLS",
                            Name = "Timor-Leste",
                            NumericCode = "626",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 223,
                            Alpha2Code = "TG",
                            Alpha3Code = "TGO",
                            Name = "Togo",
                            NumericCode = "768",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 224,
                            Alpha2Code = "TK",
                            Alpha3Code = "TKL",
                            Name = "Tokelau",
                            NumericCode = "772",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 225,
                            Alpha2Code = "TO",
                            Alpha3Code = "TON",
                            Name = "Tonga",
                            NumericCode = "776",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 226,
                            Alpha2Code = "TT",
                            Alpha3Code = "TTO",
                            Name = "Trinidad and Tobago",
                            NumericCode = "780",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 227,
                            Alpha2Code = "TN",
                            Alpha3Code = "TUN",
                            Name = "Tunisia",
                            NumericCode = "788",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 228,
                            Alpha2Code = "TR",
                            Alpha3Code = "TUR",
                            Name = "Turkey",
                            NumericCode = "792",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 229,
                            Alpha2Code = "TM",
                            Alpha3Code = "TKM",
                            Name = "Turkmenistan",
                            NumericCode = "795",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 230,
                            Alpha2Code = "TC",
                            Alpha3Code = "TCA",
                            Name = "Turks and Caicos Islands",
                            NumericCode = "796",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 231,
                            Alpha2Code = "TV",
                            Alpha3Code = "TUV",
                            Name = "Tuvalu",
                            NumericCode = "798",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 232,
                            Alpha2Code = "UG",
                            Alpha3Code = "UGA",
                            Name = "Uganda",
                            NumericCode = "800",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 233,
                            Alpha2Code = "UA",
                            Alpha3Code = "UKR",
                            Name = "Ukraine",
                            NumericCode = "804",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 234,
                            Alpha2Code = "AE",
                            Alpha3Code = "ARE",
                            Name = "United Arab Emirates",
                            NumericCode = "784",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 235,
                            Alpha2Code = "GB",
                            Alpha3Code = "GBR",
                            Name = "United Kingdom of Great Britain and Northern Ireland",
                            NumericCode = "826",
                            RegionId = 2
                        },
                        new
                        {
                            Id = 236,
                            Alpha2Code = "US",
                            Alpha3Code = "USA",
                            Name = "United States of America",
                            NumericCode = "840",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 237,
                            Alpha2Code = "UM",
                            Alpha3Code = "UMI",
                            Name = "United States Minor Outlying Islands",
                            NumericCode = "581",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 238,
                            Alpha2Code = "UY",
                            Alpha3Code = "URY",
                            Name = "Uruguay",
                            NumericCode = "858",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 239,
                            Alpha2Code = "UZ",
                            Alpha3Code = "UZB",
                            Name = "Uzbekistan",
                            NumericCode = "860",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 240,
                            Alpha2Code = "VU",
                            Alpha3Code = "VUT",
                            Name = "Vanuatu",
                            NumericCode = "548",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 241,
                            Alpha2Code = "VE",
                            Alpha3Code = "VEN",
                            Name = "Venezuela (Bolivarian Republic of)",
                            NumericCode = "862",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 242,
                            Alpha2Code = "VN",
                            Alpha3Code = "VNM",
                            Name = "Viet Nam",
                            NumericCode = "704",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 243,
                            Alpha2Code = "VG",
                            Alpha3Code = "VGB",
                            Name = "Virgin Islands (British)",
                            NumericCode = "092",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 244,
                            Alpha2Code = "VI",
                            Alpha3Code = "VIR",
                            Name = "Virgin Islands (U.S.)",
                            NumericCode = "850",
                            RegionId = 5
                        },
                        new
                        {
                            Id = 245,
                            Alpha2Code = "WF",
                            Alpha3Code = "WLF",
                            Name = "Wallis and Futuna",
                            NumericCode = "876",
                            RegionId = 4
                        },
                        new
                        {
                            Id = 246,
                            Alpha2Code = "EH",
                            Alpha3Code = "ESH",
                            Name = "Western Sahara",
                            NumericCode = "732",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 247,
                            Alpha2Code = "YE",
                            Alpha3Code = "YEM",
                            Name = "Yemen",
                            NumericCode = "887",
                            RegionId = 1
                        },
                        new
                        {
                            Id = 248,
                            Alpha2Code = "ZM",
                            Alpha3Code = "ZMB",
                            Name = "Zambia",
                            NumericCode = "894",
                            RegionId = 3
                        },
                        new
                        {
                            Id = 249,
                            Alpha2Code = "ZW",
                            Alpha3Code = "ZWE",
                            Name = "Zimbabwe",
                            NumericCode = "716",
                            RegionId = 3
                        });
                });

@ajcvickers
Copy link
Member

@voroninp We discussed this again in triage and we may consider doing something to make this more efficient when the seed data will never change. However, for now as @bricelam said above the appropriate workaround is:

If your seed data never changes, you may want to consider just adding it to the Up method of a migration and not using EntityTypeBuilder.HasData().

@ajcvickers ajcvickers changed the title Why do we need both ModelSnapshot and Migration.BuildTargetModel? Consider more efficient pattern for seed data that will never change Mar 22, 2019
@ajcvickers ajcvickers added type-enhancement and removed closed-no-further-action The issue is closed and no further action is planned. labels Mar 22, 2019
@ajcvickers ajcvickers added this to the Backlog milestone Mar 22, 2019
@voroninp
Copy link
Author

@ajcvickers I am a bit confused with word never.

The list of countries may change, enum details table changes as well when new field is added.

@ajcvickers
Copy link
Member

@voroninp then it may be that this doesn't help you, but it could still be a worthwhile enhancement.

@voroninp
Copy link
Author

@ajcvickers As an option, it would be nice to have a feature of squshing multiple migrations into a single one. After several releases it is unlikely that production will be rolled back that much.

@ajcvickers
Copy link
Member

@voroninp #2174

@mselley
Copy link

mselley commented Oct 12, 2020

You’ll still need a project reference. The compiled assembly just won’t have an assembly reference.

Moving the migrations into their own project has allowed me to again run this in azure pipelines by excluding this from the build using the configuration manager. Is this the correct way?

But this does not help us poor devs trying to rebuild and compile for debugging which takes an age. Is there a way to completely exclude this project unless using the package manager migration commands?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants