Skip to content
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

IsTemporal() with SetIsMemoryOptimized(true) generates invalid CREATE TABLE #27592

Closed
yzorg opened this issue Mar 8, 2022 · 2 comments · Fixed by #27610
Closed

IsTemporal() with SetIsMemoryOptimized(true) generates invalid CREATE TABLE #27592

yzorg opened this issue Mar 8, 2022 · 2 comments · Fixed by #27610
Assignees
Labels
area-migrations closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@yzorg
Copy link

yzorg commented Mar 8, 2022

supported in SQL 2019 - see link

  • SqlContext.cs
entity.ToTable("VendorTable1", "lookup", b =>
{
    b.IsTemporal();
    b.Metadata.SetIsMemoryOptimized(true);
})
    // not actual name, but external vendor numeric ID
    .HasIndex(e => e.Vendor_ID) 
        .IsUnique();
// external vendor-assigned string code, displayed to users
entity.HasKey(e => e.Vendor_Code);

When scripting with dotnet ef migrations script --output migrations\ef_00_initial.sql it generated invalid SQL:

  • ef_00_initial.sql
CREATE TABLE [lookup].[VendorTable1] (
    [Vendor_Code] varchar(50) NOT NULL,
    [Vendor_ID] BIGINT NOT NULL,
-- 50 more columns not shown
    [Regional_Stamp_Indicator] varchar(4) NULL,
    [PeriodEnd] datetime2 GENERATED ALWAYS AS ROW END HIDDEN NOT NULL,
    [PeriodStart] datetime2 GENERATED ALWAYS AS ROW START HIDDEN NOT NULL,
    CONSTRAINT [PK_VendorTable1] PRIMARY KEY NONCLUSTERED ([Vendor_Code]),
    PERIOD FOR SYSTEM_TIME([PeriodStart], [PeriodEnd])
) WITH (SYSTEM_VERSIONING = ON (HISTORY_TABLE = [lookup].[VendorTable1History]))
    WITH
        (MEMORY_OPTIMIZED = ON);
GO

It was really close, but added 2 "WITH" clauses instead of combining them.

version information

EF Core version: 6.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
MSSQL: SQL 2019, 15.0.4198.2
Target framework: .NET 6.0
Operating system: Win10 (production is k8s/Linux)
IDE: Visual Studio 2022
But I use dotnet ef for all scaffolding, migrations, and migration scripting.

@maumar maumar self-assigned this Mar 8, 2022
@ajcvickers
Copy link
Contributor

@yzorg Not really about this issue, but I would be interested to know how/why you are using memory-optimized tables, and the concrete performance benefits you are getting.

@roji
Copy link
Member

roji commented Mar 10, 2022

Muhahaha I got there first, issuesCount++

@roji roji added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Mar 10, 2022
roji added a commit to roji/efcore that referenced this issue Mar 10, 2022
@ghost ghost closed this as completed in #27610 Mar 10, 2022
ghost pushed a commit that referenced this issue Mar 10, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview3 Mar 15, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-preview3, 7.0.0 Nov 5, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-migrations closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants