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");
Hey Rafaela07 and cengizhanarslan
Thanks for the steer on this - both options worked but weren't quite perfect for me.
After the first refresh I got lots of invalidated relationships and my sort-by-columns disappeared. I think this is because data appears blank temporarily and then loads in.
To fix this, I got it working by creating a semply_labs notebook as you suggest that converts the a model from Direct Lake to Import Mode. You then need to follow some manual steps in PBI Desktop and then you can update the model to finalise it.
The end result is an Import Mode model and all your existing reports linked to it.
I've written this article to explain it: https://andyhowes.co/change-a-semantic-model-from-direct-lake-to-import-mode-in-microsoft-fabric/#converting-the-direct-lake-model-to-import-mode
Cheers,
Andy