Error creating memory optimized filegroup in SSDT
I am not certain whether AUTO_CLOSE is enabled or disabled by default
  after CREATE DATABASE. If ON by default, it seems that SSDT is
  generating the deployment script in the wrong order. If OFF by
  default, then I don't understand why the error exists.
  
  It seems LocalDB has hard coded use of AUTO_CLOSE, ignoring model


LocalDB / SQLEXPRESS

True, when connecting to localdb and running a standard create database command



CREATE DATABASE TEST

GO

SELECT name,database_id
FROM sys.databases 
WHERE is_auto_close_on = 1;

name    database_id
TEST    5


It appears that the is_auto_close_on is set to 1 even when model has auto_close disabled.

Normally the default settings are based on the model system database.



Resolving this issue in theory

You could create a trigger that automatically changes the auto close to 0 for newly created databases. This is a bit of a hacky approach but works.

Try / implement at your own risk.

CREATE TRIGGER Change_Auto_Close 
ON ALL SERVER 
FOR CREATE_DATABASE 
AS 
    DECLARE 
        @DatabaseName NVARCHAR(128)
        ,@SQL NVARCHAR(4000);
    SELECT 
        @DatabaseName = EVENTDATA().value('(/EVENT_INSTANCE/DatabaseName)[1]','NVARCHAR(128)')

    SET @SQL = 'USE [master] ALTER DATABASE ['+@DatabaseName+'] SET AUTO_CLOSE OFF WITH NO_WAIT;';

    IF @@TRANCOUNT = 1
    COMMIT TRAN; -- commit previous tran, otherwise we cannot alter the database
    -- PRINT @SQL;
    EXEC (@SQL);
    BEGIN TRAN; --begin new tran as not get error that the transaction ended in the trigger

GO


Ideas from here and here 



Other editions

It could be that your model database has is_auto_close_on = 1 as databases are created as a copy of model. Below are some tests with auto_close enabled and disabled on the model database.



Set auto close on for model

USE [master]
GO
ALTER DATABASE [model] SET AUTO_CLOSE ON WITH NO_WAIT;
GO


Create a default database

CREATE DATABASE AutoClosedDB;


Validate the auto close state of the newly created database

SELECT name, is_auto_close_on 
FROM sys.databases 
WHERE name = 'AutoClosedDB';


Result

name            is_auto_close_on
AutoClosedDB    1




Set auto close off for model

USE [master]
GO
ALTER DATABASE [model] SET AUTO_CLOSE OFF WITH NO_WAIT;
GO


Create a database with default settings

CREATE DATABASE NoAutoClosedDB;


Validate the auto close state of the newly created database

SELECT name, is_auto_close_on 
FROM sys.databases 
WHERE name = 'NoAutoClosedDB';


Result

name            is_auto_close_on
NoAutoClosedDB  0




Try creating a memory optimized filegroup on both databases

ALTER DATABASE NoAutoClosedDB
    ADD FILEGROUP [MemoryOptimizedFilegroup] CONTAINS MEMORY_OPTIMIZED_DATA;


Succeeds

ALTER DATABASE AutoClosedDB
    ADD FILEGROUP [MemoryOptimizedFilegroup] CONTAINS MEMORY_OPTIMIZED_DATA;


Fails with error message:


  Msg 10794, Level 16, State 125, Line 33 The operation 'AUTO_CLOSE' is
  not supported with databases that have a MEMORY_OPTIMIZED_DATA
  filegroup.




To validate the auto close state on the model database, run below script

SELECT name, is_auto_close_on 
FROM sys.databases 
WHERE name = 'model';


Disable auto close with

USE [master]
GO
ALTER DATABASE [model] SET AUTO_CLOSE OFF WITH NO_WAIT;
GO