-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
EfCore 5 update breaks behaviour of RowVersion with Conversions for InMemory database #23527
Labels
area-change-tracking
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
regression
Servicing-approved
type-bug
Milestone
Comments
Note for triage: the optimistic concurrency code in the in-memory provider assumes no value conversion. This was not an issue before 5.0 because value conversions were ignored in the in-memory database. public class DbModel
{
public long Id { get; set; }
public ulong RowVersion { get; set; }
public string Value { get; set; }
}
public class SomeDbContext : DbContext
{
private static ILoggerFactory ContextLoggerFactory
=> LoggerFactory.Create(b => b.AddConsole().SetMinimumLevel(LogLevel.Information));
public DbSet<DbModel> DbModels { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
//.UseSqlite("Data Source=test.db")
//.UseSqlServer(Your.ConnectionString)
.UseInMemoryDatabase("Test")
.UseLoggerFactory(ContextLoggerFactory)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<DbModel>(builder =>
{
builder.ToTable(name: nameof(DbModel), schema: "test");
builder.Property(po => po.RowVersion).HasConversion(new NumberToBytesConverter<ulong>()).IsRowVersion();
});
}
}
public class Program
{
public static void Main()
{
using (var context = new SomeDbContext())
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
var dbModel = new DbModel{Value = "Test"};
context.Add(dbModel);
context.SaveChanges();
var model = context.Set<DbModel>().Single();
model.Value += "2";
context.SaveChanges();
var models = context.Set<DbModel>().ToList();
Console.WriteLine($"Value is {model.Value}");
context.SaveChanges();
}
}
} |
ajcvickers
added
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
Servicing-approved
and removed
Servicing-consider
labels
Dec 3, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-change-tracking
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
regression
Servicing-approved
type-bug
Problem
There seems to be a new issue when upgrading from EfCore 3.x to 5.0 and using an Entity that contains a Property that uses a ValueConverter as well as a RowVersion. This issue affects the InMemory database provider.
Example
The following Code works in EfCore 3.1.10 but not in EfCore 5.0: full example
where the model is
Stacktrace
Provider and version information
EF Core version:
Database provider: Microsoft.EntityFrameworkCore.InMemory 5.0.0 (works with 3.1.10)
Target framework: NET 5.0
Operating system: Windows 10
The text was updated successfully, but these errors were encountered: