private string GetQualifiedResourcePath() { var resources = MigrationAssembly.GetManifestResourceNames(); //resource full name is in format `namespace.resourceName` var sqlScriptParts = SqlScript.Split('.').Reverse().ToArray(); Func <string, bool> isNameMatch = x => x.Split('.').Reverse().Take(sqlScriptParts.Length).SequenceEqual(sqlScriptParts, StringComparer.InvariantCultureIgnoreCase); string result = null; var foundResources = resources.Where(isNameMatch).ToArray(); if (foundResources.Length == 0) { throw new InvalidOperationException(string.Format("Could not find resource named {0} in assembly {1}", SqlScript, MigrationAssembly.FullName)); } if (foundResources.Length > 1) { throw new InvalidOperationException(string.Format(@"Could not find unique resource named {0} in assembly {1}. Possible candidates are: {2} ", SqlScript, MigrationAssembly.FullName, string.Join(Environment.NewLine + "\t", foundResources))); } return(foundResources[0]); }