當前生成的上下文文件命名約定是硬編碼且不可配置的。
所有的邏輯都在ReverseEngineerCodeFirstHandler
類(the source is on CodePlex)之內。
它設置而它與上創造了該方法的上下文文件名和路徑與
var contextFilePath = Path.Combine(modelsDirectory,
modelGenerator.EntityContainer.Name + contextHost.FileExtension);
var contextItem = project.AddNewFile(contextFilePath, contextContents);
因此,文件名是從modelGenerator.EntityContainer.Name
來:
var contextName =
connection.Database.Replace(" ", string.Empty)
.Replace(".", string.Empty) + "Context";
var modelGenerator =
new EntityModelSchemaGenerator(storeGenerator.EntityContainer,
"DefaultNamespace", contextName);
因此,大家可以看到工具只需要db名稱就可以刪除空格和點,並將其用作上下文名稱,這將最終生成文件名。
您可以打開issue或者 - 因爲實體框架是開源的 - 獲取代碼,添加此配置選項併發送回拉請求。
雖然它不能解決問題,但我認爲它與我們將要得到的答案一樣接近。我們找到了幾種方法來解決問題 - 當然最好的解決方案是創建拉請求。將研究這一點。謝謝您的幫助。 – CodeMonkey