是否有可能創建一個代碼優先的實體框架模型,該模型使用ODP.Net連接到現有數據庫,而無需在app.config文件中進行任何設置?如何在沒有配置文件的情況下使用Oracle Entity Framework
我嘗試過很多不同的事情。
目前我設置DbConfiguration:
sealed class EntityFrameworkConfiguration : DbConfiguration
{
public static readonly DbConfiguration Instance = new EntityFrameworkConfiguration();
EntityFrameworkConfiguration()
{
this.SetDefaultConnectionFactory(new OracleConnectionFactory());
this.SetProviderServices("Oracle.ManagedDataAccess.Client", EFOracleProviderServices.Instance);
}
}
DbConfiguration.SetConfiguration(EntityFrameworkConfiguration.Instance);
我傳遞一個OracleConnection
直接進入EF上下文。
不過,我要麼在SQL Server中的格式來產生與SQL問題(周圍使用表的別名雙引號),或者出現以下錯誤:
An unhandled exception of type 'System.NotSupportedException' occurred in EntityFramework.dll
Additional information: Unable to determine the provider name for provider factory of type 'Oracle.ManagedDataAccess.Client.OracleClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.
有沒有人得到這個的任何經驗在不污染app.config的情況下工作嗎?