Answer the question
In order to leave comments, you need to log in
Why doesn't In Memory Database autogenerate int property?
In Memory Database doesn't autogenerate int property, huh?
Trying to sequence a simple int value builder.Property
(x => x.SerialNumber).ValueGeneratedOnAdd()
after AddAsync() - 0
.net Core 3.1
Answer the question
In order to leave comments, you need to log in
Decided differently in OnModelBuilding
if (DataBase.IsInMemory())
var autoGenIntProperties = modelBuilder.Model.GetEntityTypes()
.SelectMany(t => t.GetProperties())
.Where(p => p.ClrType == typeof(int) && p.ValueGenerated != ValueGenerated.Never);
foreach (var property in autoGenIntProperties)
property.SetValueGeneratorFactory((p, t) => new InMemoryIntegerValueGenerator<int>(p.GetIndex()));
Try this solution.
https://stackoverflow.com/questions/47754939/how-t...
Other than that it looks like the problem is reoccurring, read the advice here in this thread.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question