creating SQL memory table visual studio

807 Views Asked by At

I'm trying to setup an SQL database project (using Visual Studio 2017).

I want this to create a dacpac that could be run on either SQL Server or Azure SQL, would create a database from scratch with a single publishing.

However, I'm running into couple issues:

  • I can't create a memory optimised table if there are no existing database (and tables). When running this (SQL Server):

    CREATE TABLE [dbo].[TicketReservationDetail] (
        TicketReservationID BIGINT  NOT NULL,
        TicketReservationDetailID BIGINT IDENTITY   NOT NULL,
        Quantity    INT             NOT NULL,
        FlightID    INT             NOT NULL,
        Comment      NVARCHAR (1000),
    
    CONSTRAINT [PK_TicketReservationDetail]  PRIMARY KEY NONCLUSTERED HASH
            ([TicketReservationDetailID]) WITH (BUCKET_COUNT=10000000)
    ) WITH (MEMORY_OPTIMIZED=ON);
    GO
    ALTER DATABASE [$(DatabaseName)] ADD FILEGROUP [mod] CONTAINS MEMORY_OPTIMIZED_DATA
    

It gives me this:

(63,1): SQL72014: .Net SqlClient Data Provider: Msg 10794, Level 16, State 125, Line 1 The operation 'AUTO_CLOSE' is not supported with databases that have a MEMORY_OPTIMIZED_DATA filegroup.
(63,0): SQL72045: Script execution error.  The executed script:
ALTER DATABASE [$(DatabaseName)]
     ADD FILEGROUP [mod] CONTAINS MEMORY_OPTIMIZED_DATA;

An error occurred while the batch was being executed.

However, if I publish a disk-table first then the SQL above works just fine.

I've tried having pre deployment script where I would create disk-table schema, It publishes the disk-table, and fails when it tries to publish the actual memory optimised table schema.

I've used sample database from: Ticket-reservations

Any ideas or suggestions would be appreciated.

0

There are 0 best solutions below