I'm creating a Web-API and I can't figure out how to make it use the App.config correctly. I remember there were things that needed to be done with ASP.NET in this area as well. I am currently getting this error:
{"A null was returned after calling the 'get_ProviderFactory' method on a store provider instance of type 'System.Data.OracleClient.OracleConnection'. The store provider might not be functioning correctly."}
My Web-API app runs fine and I'm sure this is just one of those configuration things that make life so difficult. My App.config is really simple:
<?xml version="1.0" encoding="utf-8"?>
<!--
Note: Add entries to the App.config file for configuration settings
that apply only to the Test project.
-->
<configuration>
<appSettings></appSettings>
<connectionStrings>
<add name="Entities" connectionString="DATA SOURCE=mltdev.world;PERSIST SECURITY INFO=True;USER ID=DEMO2_DATA" providerName="System.Data.OracleClient" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I copied most of this from the Comments demo code for the Web-API project. Any ideas? I sure would like to get my tests running.
I should have mentioned - I'm using EntifyFramework with DbContext along with the repository pattern. I will be mocking out the db piece but want ed to get some simple integration tests started for Get, Put, Post and Delete.
Ok - this is embarrassing! I found the problem and it was my connectionstring. When I copied the one from the Web.config everything ran as expected. Now I can continue forward...
thanks,
Bill44077
"every day I'm shuffling". :)
Marked as answer by bill44077 on Mar 17, 2012 05:37 PM
bill44077
Member
31 Points
60 Posts
Can't get MSTest to work with Web-API
Mar 17, 2012 04:45 PM|LINK
Hi,
I'm creating a Web-API and I can't figure out how to make it use the App.config correctly. I remember there were things that needed to be done with ASP.NET in this area as well. I am currently getting this error:
{"A null was returned after calling the 'get_ProviderFactory' method on a store provider instance of type 'System.Data.OracleClient.OracleConnection'. The store provider might not be functioning correctly."}
My Web-API app runs fine and I'm sure this is just one of those configuration things that make life so difficult. My App.config is really simple:
<?xml version="1.0" encoding="utf-8"?>
<!--
Note: Add entries to the App.config file for configuration settings
that apply only to the Test project.
-->
<configuration>
<appSettings></appSettings>
<connectionStrings>
<add name="Entities" connectionString="DATA SOURCE=mltdev.world;PERSIST SECURITY INFO=True;USER ID=DEMO2_DATA" providerName="System.Data.OracleClient" />
</connectionStrings>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I copied most of this from the Comments demo code for the Web-API project. Any ideas? I sure would like to get my tests running.
thanks!
Bill44077
bill44077
Member
31 Points
60 Posts
Re: Can't get MSTest to work with Web-API
Mar 17, 2012 05:17 PM|LINK
I should have mentioned - I'm using EntifyFramework with DbContext along with the repository pattern. I will be mocking out the db piece but want ed to get some simple integration tests started for Get, Put, Post and Delete.
bill44077
Member
31 Points
60 Posts
Re: Can't get MSTest to work with Web-API
Mar 17, 2012 05:37 PM|LINK
Ok - this is embarrassing! I found the problem and it was my connectionstring. When I copied the one from the Web.config everything ran as expected. Now I can continue forward...
thanks,
Bill44077
"every day I'm shuffling". :)
WindKnot
Member
24 Points
10 Posts
Re: Can't get MSTest to work with Web-API
Mar 17, 2012 05:38 PM|LINK
hi. i put up a test using mocks and nunit here
http://code.msdn.microsoft.com/Contact-Manager-Web-API-0e8e373d
look at the q&a - i'm aylmer
dunno if that's the sort of thing you're looking for?
bill44077
Member
31 Points
60 Posts
Re: Can't get MSTest to work with Web-API
Mar 17, 2012 05:49 PM|LINK
Very Cool Aylmer! Thanks for the good info and quick reply!!