OrmLite throwing "Method not found" exception

Hey @mythz,

I have a weird issue that has stumped for for a few hours now. I cannot seem to figure out why I get the following when running a basic AppHost:

System.MissingMethodException: Method not found: 'System.String ServiceStack.OrmLite.OrmLiteDialectProviderBase1.ResolveFragment(System.String)’`

Here is the Program.cs:

using System;

namespace OrmLiteRunner
{
  class Program
  {
    static void Main (string[] args)
    {
        var appHost = new AppHost().Init();
    }
  }
}

Here is the AppHost.cs:

using System.Linq;
using Funq;
using IM.Shared.DataModel;
using ServiceStack;
using ServiceStack.Data;
using ServiceStack.OrmLite;

namespace OrmLiteRunner
{
  public class AppHost : AppHostBase
  {
    public AppHost() : base("Temp", typeof(AppHost).Assembly) { }

    public override void Configure(Container container)
    {
      container.Register<IDbConnectionFactory>(c =>  new OrmLiteConnectionFactory("Server=XXXXX; Initial Catalog=XXXXXX; User ID=XXXXX; Password=XXXXX", SqlServer2016Dialect.Provider, true));

      using (var db = container.Resolve<IDbConnectionFactory>().OpenDbConnection())
      {
        if(db.TableExists<Country>())
          db.DropAndCreateTable<Country>();
        else
          db.CreateTableIfNotExists<Country>(); <--- This line is causing the error above, more detail below
				
        db.ExecuteSql("DBCC CHECKIDENT ('{nameof(Country)}.Id', RESEED, 0); ");

        var countries = Enumis.Constants.Iso.Countries.Cast<Country>();

        db.InsertAll(countries);
      }
    }
  }
}

Here is the Table in question:

using ServiceStack.DataAnnotations;

namespace IM.Shared.DataModel
{
  public class Country
  {
    [AutoIncrement, PrimaryKey]
    public int Id { get; set; }

    [Unique]
    public string IsoCode { get; set; }

    [Required]
    public string Name { get; set; }

    [Unique, Required]
    public string Alpha2Code { get; set; }

    [Unique, Required]
    public string Alpha3Code { get; set; }

    [Required]
    public string Nationality { get; set; }

    [Required]
    public bool ZipPostcodeRequired { get; set; }
  }
}

This isn’t a very important app but I’d still like to know what is going on to cause this? I am using the following csproj:

<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
  <OutputType>Exe</OutputType>
  <TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
  <PackageReference Include="Enumis.Constants" Version="3.1.0-unstable0023" />
  <PackageReference Include="IM.Shared.DataModel" Version="0.1.0-unstable0007" />
  <PackageReference Include="ServiceStack.OrmLite.Core" Version="5.*" />
  <PackageReference Include="ServiceStack.OrmLite.SqlServer.Core" Version="5.*" />
</ItemGroup>
<ItemGroup>
  <ProjectReference Include="..\..\..\..\IM-Developers\IM.Shared.DataModel\src\IM.Shared.DataModel\IM.Shared.DataModel.csproj" />
</ItemGroup>
</Project>

Here is the line that is causing the exception:

Lastly, I have tried this with both the .Core and base ServiceStack libraries, both acting the same way.

I’m sure you have the answer, you always do.

Thanks

@mythz,

I resolved this. I guess there was an old NuGet package. After clearing my NuGet cache, everything worked as expected.

Hopefully this helps someone else.

Thanks!