-
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
[RC1] Invalid migrations snapshot generated for key Fluent APIs #26045
Comments
Confirmed, this seems to be a result of #23848. I'll look at this ASAP. Minimal reproawait using var ctx = new BlogContext();
await ctx.Database.EnsureDeletedAsync();
await ctx.Database.EnsureCreatedAsync();
public class BlogContext : DbContext
{
public DbSet<Entity> Entities { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseSqlServer(@"Server=localhost;Database=test;User=SA;Password=Abcd5678;Connect Timeout=60;ConnectRetryCount=0");
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Entity>(entity => entity.HasKey(e => e.EntityId).IsClustered(false));
}
}
public class Entity
{
public Guid EntityId { get; set; }
public int ClusterId { get; set; }
} Creating a migration generates an invalid model snapshot. |
I started the upgrade of our platform to .NET 6 RC1 yesterday. We're also using a different clustered index to the primary keys and we're seeing exactly the same issue as the OP. |
This will be fixed in RC2. As a workaround, manually edit your context snapshots and replace the non-compiling code: SqlServerKeyBuilderExtensions.IsClustered(b, false); With the following: SqlServerKeyBuilderExtensions.IsClustered(b.HasKey("EntityId"), false); (replacing EntityId with the name of your key column(s)). |
Also generate Fluent API for IsMemoryOptimized. Fixes #26045
Also generate Fluent API for IsMemoryOptimized. Fixes #26045
Also generate Fluent API for IsMemoryOptimized. Fixes #26045
We were testing Preview 7 and it was working correctly but on RC1 we're having some typing issues with the migrations that are generated with EF Core 6.
We are using SQL Server 2019 and utilizing a different Cluster Index than our primary keys, but when ef core generates the ContextModelSnapshot it generates code that fails on build.
Include your code
Model class
Model Configuration
Partial generated code on ContextModelSnapshot
Error
Include provider and version information
EF Core version: 6.0.0-rc.1.21452.10
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 6.0
Operating system: Mac OS Big Sur 11.5.2
IDE: Rider / VsCode
The text was updated successfully, but these errors were encountered: