@@ -553,12 +553,27 @@ public override VisitedExpression Visit([NotNull] DbScanExpression expression)
553553 ScanExpression scan ;
554554 var overrideSchema = "http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator:Schema" ;
555555 if ( expression . Target . MetadataProperties . TryGetValue ( overrideSchema , false , out metadata ) && metadata . Value != null )
556- scan = new ScanExpression ( QuoteIdentifier ( metadata . Value . ToString ( ) ) + "." + QuoteIdentifier ( tableName ) , expression . Target ) ;
556+ {
557+ var schema = metadata . Value . ToString ( ) ;
558+ scan = string . IsNullOrEmpty ( schema )
559+ ? new ScanExpression ( QuoteIdentifier ( tableName ) , expression . Target )
560+ : new ScanExpression ( QuoteIdentifier ( schema ) + "." + QuoteIdentifier ( tableName ) , expression . Target ) ;
561+ }
557562 else if ( expression . Target . MetadataProperties . TryGetValue ( "Schema" , false , out metadata ) && metadata . Value != null )
558- scan = new ScanExpression ( QuoteIdentifier ( metadata . Value . ToString ( ) ) + "." + QuoteIdentifier ( tableName ) , expression . Target ) ;
563+ {
564+ var schema = metadata . Value . ToString ( ) ;
565+ scan = string . IsNullOrEmpty ( schema )
566+ ? new ScanExpression ( QuoteIdentifier ( tableName ) , expression . Target )
567+ : new ScanExpression ( QuoteIdentifier ( schema ) + "." + QuoteIdentifier ( tableName ) , expression . Target ) ;
568+ }
559569 else
560- scan = new ScanExpression ( QuoteIdentifier ( expression . Target . EntityContainer . Name ) + "." + QuoteIdentifier ( tableName ) , expression . Target ) ;
561-
570+ {
571+ var schema = expression . Target . EntityContainer . Name ;
572+ scan = string . IsNullOrEmpty ( schema )
573+ ? new ScanExpression ( QuoteIdentifier ( tableName ) , expression . Target )
574+ : new ScanExpression ( QuoteIdentifier ( schema ) + "." + QuoteIdentifier ( tableName ) , expression . Target ) ;
575+ }
576+
562577 return scan ;
563578 }
564579
0 commit comments