ASP.NET Core Problem with sequences on insert

Hey

I’m rewriting my app from ASP.NET MVC to ASP.NET Core.

just simple insert from MVC

db.Insert<Table>(new MyObject { Id = null, A = false, B = stawki.Name, C = stawki.Type, D = guid});

in Core i have:

var carriers = new Table { Id = null, A = false, B = stawki.Name, C = stawki.Type, D = guid };
Db.Insert(carriers);

Startup.cs:

container.Register<IDbConnectionFactory>(
          c=>
          {
              OrmLiteConnectionFactory dbFactory = new OrmLiteConnectionFactory(Configuration.GetConnectionString("DefaultConnection"), OracleDialect.Provider);
              dbFactory.RegisterConnection("DefaultConnection", dbFactory);
              return dbFactory;
          });

My model is:

[PrimaryKey]
[Sequence("SEQ_KT_PRZEWOZNICY_AI")]
[JsonProperty("id")]
public int? Id { get; set; }

and when trying to do just simple insert is shows:

Object reference not set to an instance of an object.at ServiceStack.OrmLite.Oracle.OracleOrmLiteDialectProvider.GetNextValue(IDbCommand dbCmd, String sequence, Object value) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite.Oracle\OracleOrmLiteDialectProvider.cs:line 838
at ServiceStack.OrmLite.Oracle.OracleOrmLiteDialectProvider.SetParameterValues[T](IDbCommand dbCmd, Object obj) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite.Oracle\OracleOrmLiteDialectProvider.cs:line 355
at ServiceStack.OrmLite.OrmLiteWriteCommandExtensions.Insert[T](IDbCommand dbCmd, T obj, Action1 commandFilter, Boolean selectIdentity) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteWriteCommandExtensions.cs:line 687 at ServiceStack.OrmLite.OrmLiteWriteApi.<>c__DisplayClass5_01.b__0(IDbCommand dbCmd) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteWriteApi.cs:line 72
at ServiceStack.OrmLite.OrmLiteExecFilter.Exec[T](IDbConnection dbConn, Func`2 filter) in C:\BuildAgent\work\27e4cc16641be8c0\src\ServiceStack.OrmLite\OrmLiteExecFilter.cs:line 64
at KT.Repository.StawkiRepository.Add(StawkiListModel stawki) in C:\Users\marcin.basiaga\Desktop\KThh\KT\KT\Repository\StawkiRepository.cs:line 42
at KT.Controllers.StawkiController.AddStawki(StawkiListModel stawki) in C:\Users\marcin.basiaga\Desktop\KThh\KT\KT\Controllers\StawkiController.cs:line 76

It seems to be problem with sequences cause if y do insert of MyObject = { Id= 545,…} it’s insert

any ideas?

You can try using the latest Oracle version from v5.5.1 on MyGet where there was recently a PR merged to fix an issue with Oracle sequences.

Please note the Oracle provider is only community supported, i.e. they’ve been contributed and maintained by the community, we only merge PR’s we don’t maintain it ourselves.

Is it solved in 5.5.1 cause it won’t work? Or will be released in 5.5.2? I am asking cause it holds my rewriting projects from MVC to Core without writing triggers :smile:

I can only tell you I remember seeing a a PR merged that resolved an issue with Sequences in Oracle.

The Oracle provider is an unofficial provider which was community contributed, we don’t use, develop, maintain or support it ourselves. We just merge PR’s from the external ServiceStack community that use Oracle who send in PR’s to resolve issues that they run into.