.NET ODP Managed Driver user mapping not working - asp.net

I'm using EF6 ModelFirst and Oracle ODP Managed driver 12c to develop .NET application (One solution containing solely one project)
I run into a mapping problem between Oracle and .NET.
I'm trying to specify custom mapping in web.config like that :
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1" />
<add name="byte" precision="3" />
<add name="int16" precision="4" />
<add name="int32" precision="9" />
<add name="int64" precision="18" />
</edmMapping>
</edmMappings>
<dataSources>
...
</dataSources>
</version>
</oracle.manageddataaccess.client>
After generating the .edmx, number(5) columns are still mapped into "short" .NET Type (Int16)
Obviously, this .NET Type is not suitable for ZIP code like 59000
If I modify the column mapping from Int16 to Int32 Type in the .edmx, I get the 2019 error specifying that I've got bad mapping
Workaround: When I modify the xml version of the edmx, if I delete the precision of the column it works with Int32 but after updating the model from database, the modifications are overwritten.

The edmMappings syntax has changed with EF 6.
You must now use the following syntax:
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmNumberMapping>
<add NETType="bool" MinPrecision="1" MaxPrecision="1" DBType="Number" />
<add NETType="byte" MinPrecision="2" MaxPrecision="3" DBType="Number" />
<add NETType="int16" MinPrecision="4" MaxPrecision="4" DBType="Number" />
<add NETType="int32" MinPrecision="5" MaxPrecision="9" DBType="Number" />
<add NETType="int64" MinPrecision="10" MaxPrecision="18" DBType="Number" />
</edmNumberMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
You now need to specify the DBType on every line rather than as an attribute to the mapping section.
You also use NETType rather than name.
And finally you must define a min and max precision.
Documentation link: Oracle Number Default Data Type Mapping and Customization Under section Entity Framework 6 Mapping and Customization

Related

Application Insights: Some metrics not coming through, unsure how to respond to error messages

I'm new to Application Insights.
The details in this ticket relate to a specific API, written in C# with .NET Framework (not Core), running in IIS on a Windows Server 2012 R2 Datacenter virtual machine.
We have a lot of the Application Insights metrics for this API coming through as expected, including some custom telemetry we coded ourselves that has been extremely useful.
But a few key things such as the requests per second and the failed requests per second are not coming through.
I've done some digging, and I've found some trace information in the Application Insights logs for that specific API that look like they might be related, but I'm not sure what to do with them.
Here's one example:
AI: Error collecting 3 of the configured performance counters. Please check the configuration.
Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests/Sec: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Requests/Sec, instance _LM_W3SVC_4_ROOT
Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Request Execution Time: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Request Execution Time, instance _LM_W3SVC_4_ROOT
Counter \ASP.NET Applications(??APP_W3SVC_PROC??)\Requests In Application Queue: Failed to perform the first read for performance counter. Please make sure it exists. Category: ASP.NET Applications, counter: Requests In Application Queue, instance _LM_W3SVC_4_ROOT
Another example:
AI: ApplicationInsights configuration file loading failed. Type 'Microsoft.ApplicationInsights.StatusMonitor.SdkSourceTelemetryInitializer, Microsoft.AI.StatusMonitor' was not found. Type loading was skipped. Monitoring will continue.
Here's the ApplicationInsights.config file for the website in question:
<?xml version="1.0" encoding="utf-8"?>
<ApplicationInsights xmlns="http://schemas.microsoft.com/ApplicationInsights/2013/Settings">
<TelemetryInitializers>
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.HttpDependenciesParsingTelemetryInitializer, Microsoft.AI.DependencyCollector" />
<Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer" />
<Add Type="Microsoft.ApplicationInsights.WindowsServer.AzureWebAppRoleEnvironmentTelemetryInitializer, Microsoft.AI.WindowsServer" />
<Add Type="Microsoft.ApplicationInsights.WindowsServer.BuildInfoConfigComponentVersionTelemetryInitializer, Microsoft.AI.WindowsServer" />
<Add Type="Microsoft.ApplicationInsights.Web.WebTestTelemetryInitializer, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.Web.SyntheticUserAgentTelemetryInitializer, Microsoft.AI.Web">
<!-- Extended list of bots:
search|spider|crawl|Bot|Monitor|BrowserMob|BingPreview|PagePeeker|WebThumb|URL2PNG|ZooShot|GomezA|Google SketchUp|Read Later|KTXN|KHTE|Keynote|Pingdom|AlwaysOn|zao|borg|oegp|silk|Xenu|zeal|NING|htdig|lycos|slurp|teoma|voila|yahoo|Sogou|CiBra|Nutch|Java|JNLP|Daumoa|Genieo|ichiro|larbin|pompos|Scrapy|snappy|speedy|vortex|favicon|indexer|Riddler|scooter|scraper|scrubby|WhatWeb|WinHTTP|voyager|archiver|Icarus6j|mogimogi|Netvibes|altavista|charlotte|findlinks|Retreiver|TLSProber|WordPress|wsr-agent|http client|Python-urllib|AppEngine-Google|semanticdiscovery|facebookexternalhit|web/snippet|Google-HTTP-Java-Client-->
<Filters>search|spider|crawl|Bot|Monitor|AlwaysOn</Filters>
</Add>
<Add Type="Microsoft.ApplicationInsights.Web.ClientIpHeaderTelemetryInitializer, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.Web.OperationNameTelemetryInitializer, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.Web.OperationCorrelationTelemetryInitializer, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.Web.UserTelemetryInitializer, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.Web.AuthenticatedUserIdTelemetryInitializer, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.Web.AccountIdTelemetryInitializer, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.Web.SessionTelemetryInitializer, Microsoft.AI.Web" />
<Add Type="Microsoft.ApplicationInsights.StatusMonitor.SdkSourceTelemetryInitializer, Microsoft.AI.StatusMonitor" />
</TelemetryInitializers>
<TelemetryModules>
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
<ExcludeComponentCorrelationHttpHeadersOnDomains>
<!--
Requests to the following hostnames will not be modified by adding correlation headers.
This is only applicable if Profiler is installed via either StatusMonitor or Azure Extension.
Add entries here to exclude additional hostnames.
NOTE: this configuration will be lost upon NuGet upgrade.
-->
<Add>core.windows.net</Add>
<Add>core.chinacloudapi.cn</Add>
<Add>core.cloudapi.de</Add>
<Add>core.usgovcloudapi.net</Add>
</ExcludeComponentCorrelationHttpHeadersOnDomains>
</Add>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.PerformanceCollectorModule, Microsoft.AI.PerfCounterCollector">
<!--
Use the following syntax here to collect additional performance counters:
<Counters>
<Add PerformanceCounter="\Process(??APP_WIN32_PROC??)\Handle Count" ReportAs="Process handle count" />
...
</Counters>
PerformanceCounter must be either \CategoryName(InstanceName)\CounterName or \CategoryName\CounterName
NOTE: performance counters configuration will be lost upon NuGet upgrade.
The following placeholders are supported as InstanceName:
??APP_WIN32_PROC?? - instance name of the application process for Win32 counters.
??APP_W3SVC_PROC?? - instance name of the application IIS worker process for IIS/ASP.NET counters.
??APP_CLR_PROC?? - instance name of the application CLR process for .NET counters.
-->
</Add>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryModule, Microsoft.AI.PerfCounterCollector" />
<Add Type="Microsoft.ApplicationInsights.WindowsServer.DeveloperModeWithDebuggerAttachedTelemetryModule, Microsoft.AI.WindowsServer" />
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnhandledExceptionTelemetryModule, Microsoft.AI.WindowsServer" />
<Add Type="Microsoft.ApplicationInsights.WindowsServer.UnobservedExceptionTelemetryModule, Microsoft.AI.WindowsServer" />
<Add Type="Microsoft.ApplicationInsights.Web.RequestTrackingTelemetryModule, Microsoft.AI.Web">
<Handlers>
<!--
Add entries here to filter out additional handlers:
NOTE: handler configuration will be lost upon NuGet upgrade.
-->
<Add>System.Web.Handlers.TransferRequestHandler</Add>
<Add>Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.RequestDataHttpHandler</Add>
<Add>System.Web.StaticFileHandler</Add>
<Add>System.Web.Handlers.AssemblyResourceLoader</Add>
<Add>System.Web.Optimization.BundleHandler</Add>
<Add>System.Web.Script.Services.ScriptHandlerFactory</Add>
<Add>System.Web.Handlers.TraceHandler</Add>
<Add>System.Web.Services.Discovery.DiscoveryRequestHandler</Add>
<Add>System.Web.HttpDebugHandler</Add>
</Handlers>
</Add>
<Add Type="Microsoft.ApplicationInsights.Web.ExceptionTrackingTelemetryModule, Microsoft.AI.Web" />
</TelemetryModules>
<TelemetryChannel Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.ServerTelemetryChannel, Microsoft.AI.ServerTelemetryChannel" />
<TelemetryProcessors>
<Add Type="Microsoft.ApplicationInsights.Extensibility.PerfCounterCollector.QuickPulse.QuickPulseTelemetryProcessor, Microsoft.AI.PerfCounterCollector" />
<Add Type="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel.AdaptiveSamplingTelemetryProcessor, Microsoft.AI.ServerTelemetryChannel">
<MaxTelemetryItemsPerSecond>5</MaxTelemetryItemsPerSecond>
</Add>
</TelemetryProcessors>
<!--
Learn more about Application Insights configuration with ApplicationInsights.config here:
http://go.microsoft.com/fwlink/?LinkID=513840
Note: If not present, please add <InstrumentationKey>Your Key</InstrumentationKey> to the top of this file.
-->
<InstrumentationKey>**removed**</InstrumentationKey>
<ResourceID>**removed**</ResourceID>
<StatusMonitor>2.3.0</StatusMonitor>
</ApplicationInsights>
The host machine is running Windows Server 202 R2 Datacenter as part of an Azure VM.
Because I'm new to this, I'm not really sure where to start. I've tried googling the error messages but I'm not coming up with much that seems useful to my current situation.
Any pointers in the right direction greatly appreciated.
What is the version of the SDKs you are using? And did you add application insights SDK to the application itself, or used Status Monitor to instrument the app at runtime?
The error about PerfCounters indicates that the SDK encountered error trying to collect the counters mentioned. Are you seeing other counters like Process CPU, Memory etc? If yes, then the issue is with Asp.Net related counters only. Can you use a tool like perfmon and validate that these counters do exist in the machine?
You can remove the following line from Ai.Config to get rid of the error about StatusMonitor initialier - I am not sure what does it do, but it cannot explain why you are missing some data.
<Add Type="Microsoft.ApplicationInsights.StatusMonitor.SdkSourceTelemetryInitializer, Microsoft.AI.StatusMonitor" />
To really explain why you are not seeing 'Requests' related metric, need to see web.config of your application. You may be hitting this issue:
https://github.com/Microsoft/ApplicationInsights-dotnet-server/issues/569
Please share some more information - sdk version, web.config, how onboarded etc and I am try to help more.

Getting BitcoinLib Error = "One or more required parameters, as defined in CoinParameters, were not found in the configuration file!"

I'm using BitcoinLib in my ASP.NET Core (v2) Web Api project. However, whenever I try to instantiate the service:
var bitcoinService = new BitcoinLib.Services.Coins.Bitcoin
.BitcoinService(appSettings.BitcoinSettings.ServerUrl,
appSettings.BitcoinSettings.Username,
appSettings.BitcoinSettings.Password,
appSettings.BitcoinSettings.WalletPassword);
I get the error:
One or more required parameters, as defined in CoinParameters, were not found in the configuration file!
I verified that the values that are being passed in are not null and correct, I've even added the settings to my web.config:
<configuration>
<appSettings>
<add key="RpcRequestTimeoutInSeconds" value="60" />
<add key="Bitcoin_DaemonUrl" value="http://localhost:18332" />
<add key="Bitcoin_DaemonUrl_Testnet" value="http://localhost:18332" />
<add key="Bitcoin_WalletPassword" value="X" />
<add key="Bitcoin_RpcUsername" value="X" />
<add key="Bitcoin_RpcPassword" value="X" />
</appSettings>
...
Nothing works... do I need to fork this thing and remove that IgnoreConfigFiles check or am I doing something wrong here?
The exception showing was a misdirection... the actual problem was with rpcRequestTimeoutInSeconds. The library needs to have an overload like this:
BitcoinService(string daemonUrl, string rpcUsername, string rpcPassword, string walletPassword, short rpcRequestTimeoutInSeconds)
It looks like the NuGet package is missing it? As I can see it in the code...
More info here:
https://github.com/GeorgeKimionis/BitcoinLib/issues/42
I did create a .NET Core compatible one here:
https://github.com/SaganMarketing/BitcoinLib
You can get a package here:
https://www.myget.org/feed/saganmarketing/package/nuget/BitcoinLib

odp.net ora-12154:TNS:Could not resolve the connect identifier specified

I am trying to create entity fm on asp.net MVC 5 with existing oracle database.I installed Oracle.ManageDataAccess & Entity client from nuget pm. But I am still getting this error when try to create entity framwork using ADO.NET.
TNS:Could not resolve the connect identifier specified
Here is I have done in web.config with related Oracle Client and connectionString:
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="TNS_ADMIN" value="C:\app\tcetin\product\12.1.0\dbhome_1\NETWORK\ADMIN" />
</settings>
<dataSources>
<dataSource alias="SptsDataSource" descriptor="(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=******)(PORT=1521))(CONNECT_DATA=(SERVER=dedicated)(SERVICE_NAME=*****)))" />
</dataSources>
</version>
</oracle.manageddataaccess.client>
<connectionStrings>
<add name="OracleDbContext" providerName="Oracle.ManagedDataAccess.Client" connectionString="User Id=****;Password=*****;Data Source=SptsDataSource" />
</connectionStrings>
How can I solve this issue?
Thanks
I don't think this is your problem, but you are referencing a TNS_ADMIN, but then specifying your datasource directly. You shouldn't need the TNS_ADMIN part when specifying the datasource directly. My guess is your datasource definition isn't quite right.

Oracle.ManagedDataAccess: TNS:could not resolve the connect identifier specified

I'm getting the following error while trying to connect to an Oracle database from a new ASP.NET MVC 4 application: "ORA-12154: TNS:could not resolve the connect identifier specified". I'm using the Oracle.ManagedDataAccess DLL (version 4.121.1.0) to try to connect to an Oracle 10g database. Here's the thing - I have an integration test assembly that is successfully connecting to the database using this minimal App.config:
<connectionStrings>
<add name="OracleConnection" connectionString="DATA SOURCE=TNS_NAME;PASSWORD=xxx;PERSIST SECURITY INFO=True;USER ID=xxx" providerName="Oracle.ManagedDataAccess.Client" />
</connectionStrings>
However, if I try to run my web app with all the crazy Web.config settings, I'm getting the error "ORA-12154: TNS:could not resolve the connect identifier specified". What am I doing wrong? Why is my config for the integration test assembly so simple and the Web.config so complex? Here's the pertinent sections of my Web.config (taken from Deploying and Configuring ODP.NET to work without installation with Entity Framework):
custom configSection:
<configSections>
<section name="oracle.manageddataaccess.client"
type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</configSections>
the corresponding config section:
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
</edmMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
custom system.data node:
<system.data>
<DbProviderFactories>
Remove in case this is already defined in machine.config
<remove invariant="Oracle.DataAccess.Client" />
<remove invariant="Oracle.ManagedDataAccess.Client" />
<add name="ODP.NET, Managed Driver" invariant="Oracle.ManagedDataAccess.Client"
description="Oracle Data Provider for .NET, Managed Driver"
type="Oracle.ManagedDataAccess.Client.OracleClientFactory, Oracle.ManagedDataAccess, Version=4.121.1.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</DbProviderFactories>
</system.data>
EntityFramework node:
<entityFramework>
<defaultConnectionFactory type="Victoria.Data.OracleConnectionFactory, EntityFramework" />
</entityFramework>
Update 1: After reading through http://docs.oracle.com/cd/E16655_01/win.121/e17732/featConfig.htm#ODPNT8161, I tried modifying my Web.config oracle.manageddataaccess.client to the following and it works. However, it doesn't seem right to have the connectionString node referencing the TNS name AND this extra reference to the same TNS Names file.
<oracle.manageddataaccess.client>
<version number="*">
<dataSources>
<dataSource alias="SIEBMATS" descriptor="(DESCRIPTION=(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = xxx.yyy.zzz)(PORT = 1521)))(CONNECT_DATA =(SERVICE_NAME = siebmats)))" />
</dataSources>
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
</edmMapping>
</edmMappings>
</version>
</oracle.manageddataaccess.client>
One thing you can try is having the connection string like so:
connectionString="Data Source=//SERVER:PORT/INSTANCE_NAME;USER=XXX;PASSWORD=XXX".
Useful references here:
http://www.connectionstrings.com/oracle/
http://docs.oracle.com/cd/E51173_01/win.122/e17732/featConnecting.htm#ODPNT169
This has also helped me while having problems with EF:
Deploying and Configuring ODP.NET to work without installation with Entity Framework
Hope to have helped.
My problem was in incorrect/incomplete Oracle Driver version, had 11.2.0 installed. I add another 12.2.0 version, didn't change anything in web.config and it worked as charm
I suggest to try the solution proposed by #kolbasov in another thread but about the same problem: https://stackoverflow.com/a/20050462/9390179
It worked for me:
<oracle.manageddataaccess.client>
<version number="*">
<settings>
<setting name="TNS_ADMIN" value="C:\Oracle\product\11.1.0\client_1\network\admin" />
</settings>
</version>
</oracle.manageddataaccess.client>

Why might this ASP.NET profile section fail to dynamically compile?

When the following profile section is in my web.config, the first page request fail with FileNotFoundException and a bunch of error coming from the compiler (from the look of the stack trace). When the properties section is removed, everything works again (until I try to reference something from the Profile of course). The rest of the website is pre-compiled, assembly per page, not-updatable.
The problem has only been reproduced on one machine-- the same build worked on other highly similar machines.
Am I missing anything obvious?
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider"
connectionStringName="ConnectionString"
applicationName="OIWebApps"
type="System.Web.Profile.SqlProfileProvider"/>
</providers>
<properties>
<group name="UI">
<add name="MasterPage" defaultValue="Horizontal.master"/>
<add name="Theme" defaultValue="Default"/>
<add name="IsSessionWarningEnabled" defaultValue="True" type="System.Boolean"/>
<add name="UseTelerikMultilineTextBoxes" defaultValue="True" type="System.Boolean"/>
<add name="FontSize" defaultValue="Smaller" type="System.String"/>
</group>
</properties>
</profile>
I see "UseTelereikMultilineTextBoxes". Could it be that a file needed for Telerik is missing on this machine?
It failed to compile because of a missing native .dll It was extremely hard to identify because the page that was executing didn't directly use the .net dll that depended on the missing native .dll, and even more confusingly, only some pages raised the compile error instead of being raised on all pages.

Resources