我正在使用Code First EF和Oracle ODP.Net,我正在尝试通过VS2012内的“EF Powertools Beta 3”重新生成视图。
我最近开始在视图生成上遇到错误,我之前没有,所以我猜我有一些配置错误,因为错误与SQL Server而不是Oracle有关。
完整错误的依据是:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
System.Data.ProviderIncompatibleException: An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. Check the inner exceptions for details and ensure that the connection string is correct. --->
System.Data.ProviderIncompatibleException: The provider did not return a ProviderManifestToken string. --->
System.Data.SqlClient.SqlException: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)
我当前的app.config是:
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<dataConfiguration defaultDatabase="STD" />
<connectionStrings>
<add name="STD" connectionString="Data Source=localhost:1521/ora10g01;Persist Security Info=false;User ID=user;Password=pass;Connection Timeout=30;Decr Pool Size=1;Incr Pool Size=5;Min Pool Size=1;Max Pool Size=20;Pooling=true;" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="STDConnectionFactory, STD.DataAccess">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
有没有人知道我错误的配置是什么?
答案 0 :(得分:0)
看起来这是配置问题。
当我将连接字符串上的名称更改为Context类名称时,在我提供连接字符串提供程序名称后,EF电源工具成功生成了我的视图。
我还从DataAccess项目(包含EF代码)中删除了所有配置,而是将配置添加到主WebService项目中,该项目调用DataAccess层。
我使用的最终配置是:
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<dataConfiguration defaultDatabase="STD" />
<connectionStrings>
<add name="STDContext" providerName="Oracle.DataAccess.Client" connectionString="Data Source=localhost:1521/ora10g01;Persist Security Info=false;User ID=user;Password=pass;Connection Timeout=30;Decr Pool Size=1;Incr Pool Size=5;Min Pool Size=1;Max Pool Size=20;Pooling=true;" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="STDConnectionFactory, STD.DataAccess">
<parameters>
<parameter value="NICK />
</parameters>
</defaultConnectionFactory>
</entityFramework>
</configuration>
我不能保证这对每个人都有用,但它可能会帮助别人!