Forum Discussion
Switch from Direct Lake to Import Mode
- 8 months ago
The warning happens because it requires a refresh operation since it is still directlake. Sorry for misunderstanding here. To convert the your model to Import mode you could use the following c# code through Tabular Editor after connecting to your model. After running it you should use Model --> Deploy option to deploy the newly converted model as a new model in a workspace.
using System.Reflection;
const string mImportTemplate =
@"let
Source = DatabaseQuery,
Data = Source{{[Schema=""{0}"",Item=""{1}""]}}[Data]
in
Data";foreach (var table in Model.Tables)
{
if (table.Partitions.Count != 1) continue;var partition = table.Partitions[0];
if (partition.Mode != ModeType.DirectLake) continue;var pMetadataObjct =
typeof(Partition).GetProperty(
"MetadataObject",
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);var tomPartition =
pMetadataObjct.GetValue(partition)
as Microsoft.AnalysisServices.Tabular.Partition;var tomPartitionSource =
tomPartition.Source
as Microsoft.AnalysisServices.Tabular.EntityPartitionSource;if (tomPartitionSource == null) continue;
var schemaName = tomPartitionSource.SchemaName;
var tableName = tomPartitionSource.EntityName;var partitionName = partition.Name;
partition.Name += "_old";table.AddMPartition(
partitionName,
string.Format(mImportTemplate, schemaName, tableName));partition.Delete();
}Model.Collation = null;
Model.DefaultMode = ModeType.Import;
Model.RemoveAnnotation("TabularEditor_DirectLake");
Hi,
The fastest and cleanest way to switch an existing Direct Lake semantic model to Import mode—without rebuilding reports—is by using a notebook-based approach in Microsoft Fabric, leveraging semantic-link-labs.
Below is a step-by-step solution.
Step 1: Install semantic-link-labs
Run the following in a Fabric notebook:
Step 2: Duplicate the semantic model and switch it to Import mode
This step extracts the existing semantic model definition and recreates it as a new Import-mode model in the target workspace.
This effectively duplicates the Direct Lake semantic model as an Import model, without needing Power BI Desktop.
Step 3: Rebind existing reports to the new Import semantic model
Once the new model exists, you can rebind existing reports so they point to the new Import-mode dataset.
- Rafaela078 months ago
Helper I
Hi cengizhanarslan
This indead duplicates the semantic model however the tables inside still appear in direct lake and there is also a warning sign. So I'm don't think that this approach works- cengizhanarslan8 months ago
Super User
The warning happens because it requires a refresh operation since it is still directlake. Sorry for misunderstanding here. To convert the your model to Import mode you could use the following c# code through Tabular Editor after connecting to your model. After running it you should use Model --> Deploy option to deploy the newly converted model as a new model in a workspace.
using System.Reflection;
const string mImportTemplate =
@"let
Source = DatabaseQuery,
Data = Source{{[Schema=""{0}"",Item=""{1}""]}}[Data]
in
Data";foreach (var table in Model.Tables)
{
if (table.Partitions.Count != 1) continue;var partition = table.Partitions[0];
if (partition.Mode != ModeType.DirectLake) continue;var pMetadataObjct =
typeof(Partition).GetProperty(
"MetadataObject",
BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.DeclaredOnly);var tomPartition =
pMetadataObjct.GetValue(partition)
as Microsoft.AnalysisServices.Tabular.Partition;var tomPartitionSource =
tomPartition.Source
as Microsoft.AnalysisServices.Tabular.EntityPartitionSource;if (tomPartitionSource == null) continue;
var schemaName = tomPartitionSource.SchemaName;
var tableName = tomPartitionSource.EntityName;var partitionName = partition.Name;
partition.Name += "_old";table.AddMPartition(
partitionName,
string.Format(mImportTemplate, schemaName, tableName));partition.Delete();
}Model.Collation = null;
Model.DefaultMode = ModeType.Import;
Model.RemoveAnnotation("TabularEditor_DirectLake");- v-menakakota8 months ago
Community Support
Hi Rafaela07 ,
Thanks for reaching out to the Microsoft fabric community forum.
I would also take a moment to thank cengizhanarslan , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you .
Best Regards,
Community Support Team