efcore: EF & MAUI Android Release - Format of the initialization string does not conform to specification starting at index 0

Description

But I have discovered that my application runs successfully with EFCore-SQLite only in debug. Whenever I publish for android then crash at startup.

EFCore version: 8.0.0 MAUI version: 8.0.3

android.runtime.JavaProxyThrowable: [System.ArgumentNullException]: ArgumentNull_Generic Arg_ParamName_Name, source
	at System.Linq.ThrowHelper.ThrowArgumentNullException(Unknown Source:0)
	at System.Linq.Enumerable.All(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.ValueGenerationConvention.GetValueGenerated(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.RelationalValueGenerationConvention.GetValueGenerated(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.RelationalValueGenerationConvention.GetValueGenerated(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.ValueGenerationConvention.ProcessEntityTypePrimaryKeyChanged(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ImmediateConventionScope.OnEntityTypePrimaryKeyChanged(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+OnEntityTypePrimaryKeyChangedNode.Run(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+DelayedConventionScope.Run(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ConventionBatch.Run(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ConventionBatch.Dispose(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ImmediateConventionScope.OnModelInitialized(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.OnModelInitialized(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Metadata.Internal.Model..ctor(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.ModelBuilder..ctor(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.ModelConfigurationBuilder.CreateModelBuilder(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel(Unknown Source:0)
	at Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model(Unknown Source:0)

Steps to Reproduce

No response

Link to public reproduction project repository

https://github.com/Igor-9309/MauiApp9.git

Version with bug

Unknown/Other

Is this a regression from previous behavior?

Yes, this used to work in .NET MAUI

Last version that worked well

7.0.101

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

No response

Relevant log output

No response

About this issue

  • Original URL
  • State: open
  • Created 8 months ago
  • Reactions: 2
  • Comments: 33 (14 by maintainers)

Most upvoted comments

Hi!

Yes, this is how it works, and from my side, the issue can be considered closed.

Thx

Got the same error after upgrading to .NET 8. As mentioned before by @Igor-9309 not while debugging, only after the App has been published to Android. Downgrading back to <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.14" /> solved the issue.

System.ArgumentNullException:
   at System.Linq.ThrowHelper.ThrowArgumentNullException (System.Linq, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
   at System.Linq.Enumerable.All (System.Linq, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.ValueGenerationConvention.GetValueGenerated (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.RelationalValueGenerationConvention.GetValueGenerated (Microsoft.EntityFrameworkCore.Relational, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.RelationalValueGenerationConvention.GetValueGenerated (Microsoft.EntityFrameworkCore.Relational, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.ValueGenerationConvention.ProcessForeignKeyAdded (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ImmediateConventionScope.OnForeignKeyAdded (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+OnForeignKeyAddedNode.Run (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+DelayedConventionScope.Run (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ConventionBatch.Run (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ConventionBatch.Dispose (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher+ImmediateConventionScope.OnModelInitialized (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.OnModelInitialized (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Metadata.Internal.Model..ctor (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.ModelBuilder..ctor (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.ModelConfigurationBuilder.CreateModelBuilder (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.GetModel (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)
   at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel (Microsoft.EntityFrameworkCore, Version=8.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60)

This apparently is because EFCore 8 doesn’t yet support things like AOT compilation, and support for that may not come for a while: https://github.com/dotnet/efcore/issues/29761. However, you can safely drop back to EFCore 7 while using MAUI 8.

This is a runtime issue. Filed an issue with a repro that doesn’t reference EF - https://github.com/dotnet/runtime/issues/96264

dotnet/runtime is probably the right place, it sounds like an efcore change in 8.0 that is hitting some problem in the mono codegen. @steveisok can you take a look.

Can someone explain to me why EF Core 7 works while EF Core 8 does not ? What’s the difference ?

I added the Release option to generate logs. https://github.com/Igor-9309/MauiApp9-NOAOT.git dotnet build .\MauiApp9.sln /bl:out.binlog -p:Configuration=Release

out.zip