Since EF is an open source environment, the easiest way to find this is to look at the source code:
protected internal void SqlResource(string sqlResource, Assembly resourceAssembly = null, bool suppressTransaction = false, object anonymousArguments = null) { Check.NotEmpty(sqlResource, "sqlResource"); resourceAssembly = resourceAssembly ?? Assembly.GetCallingAssembly(); if (!resourceAssembly.GetManifestResourceNames().Contains(sqlResource)) { throw new ArgumentException(Strings.UnableToLoadEmbeddedResource(resourceAssembly.FullName, sqlResource)); } using (var textStream = new StreamReader(resourceAssembly.GetManifestResourceStream(sqlResource))) { AddOperation( new SqlOperation(textStream.ReadToEnd(), anonymousArguments) { SuppressTransaction = suppressTransaction }); } }
Here you can see that this method first reads a manifest resource named sqlResource from the resourceAssembly assembly (if null, it uses the calling assembly). Then the text from this resource is processed as sql, and the regular SqlOperation added along with it and the parameters that you provide.
There are many ways to insert an arbitrary file as a manifest resource into your assembly. An easy way for this particular situation is to simply add this file to the project using the "Embedded Resource" build action. So you have a sql file called "CreateTables.sql". Right-click on the Visual Studio project, click Add> Existing Item, select the CreateTables.sql file, then right-click on it in the Visual Studio project and select Build Action as βEmbedded Resource.β This will result in the manifest a resource named DefaultNamespaceOfYourAssembly.Folder.SubFolder.CreateTables.sql (if you put it in the root directory without folders, and then obviously skip the Folder.SubFolder part), which you can then use as sqlResource in the above method.
As for the resx file you mentioned - this file is a manifest resource, but it cannot be used here because you cannot use only part of it (so there is some resource with this key) - you can use it only as a whole, but This is an xml file, not sql.
Evk
source share