Function imports for entity framework with odp.net managed driver - entity-framework

I recently switched from ODP Unmanaged to ODP Managed (in conjunction with Entity Framework).
The Unmanaged drivers were working fine after adding the necessary information in the web.config section. I could add the stored procedures and generate the complex types using the Function Import - Get Column information (I'm trying to import a stored procedure with an OUT refcursor parameter).
After the switch the config section was updated to reflect the new format and everything works at runtime (so the format is correct).
However when I try to generate the complex types again (or add a new Function Import) I just get a System.notSupportedException Message: The specified type is not supported by this selector) Without any indication which type/selector it is (obviously)...
Google has turned up nothing and the thread on the Oracle Forums has gathered no response as well.
Versions:
ODP.Net (ODAC) : v12.1 (Production release; DLL v4.121.1.0)
EF v5
.NET v4.5
Config file (trimmed a bit):
<configSections>
<section name="oracle.manageddataaccess.client" type="OracleInternal.Common.ODPMSectionHandler, Oracle.ManagedDataAccess"/>
</configSections>
<oracle.manageddataaccess.client>
<version number="*">
<edmMappings>
<edmMapping dataType="number">
<add name="bool" precision="1"/>
<add name="byte" precision="2" />
<add name="int16" precision="5" />
<add name="int32" precision="10" />
<add name="int64" precision="38" />
</edmMapping>
</edmMappings>
<implicitRefCursor>
<storedProcedure schema="ECOM" name="SHP_API_ORDERS.CREATE_ORDER">
<refCursor name="O_RS">
<bindInfo mode="Output"/>
<metadata columnOrdinal="0" columnName="COL1" nativeDataType="Number" providerType="Decimal" allowDBNull="false" numericPrecision="10" numericScale="0" />
<metadata columnOrdinal="1" columnName="COL2" nativeDataType="Date" providerType="Date" allowDBNull="true" />
<metadata columnOrdinal="2" columnName="COL3" nativeDataType="Varchar2" providerType="Varchar2" allowDBNull="false" columnSize="10" />
</refCursor>
</storedProcedure>
</implicitRefCursor>
</version>
</oracle.manageddataaccess.client>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<system.data>
<DbProviderFactories>
<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>

The implicit ref cursor config file format is different between Unmanaged ODP.NET and Managed ODP.NET. That might be part of your problem.
To save yourself from pulling your hair out, install the latest Oracle Developer Tools for Visual Studio (ODT) and use the new feature that automatically generates this config:
1) Install ODT 12.1 if you haven't already
2) Find the stored procedure in server explorer, right click it and run it, and enter input parameters.
3) For the output ref cursor that represents the return value for your Entity Function, choose "Add to Config" checkbox.
4) Then select either "Show Config" (and then cut and paste) or "Add to Config".
Here is a screenshot of what I am talking about:
http://i.imgur.com/t1BfmUP.gif
If this doesn't fix the problem, play around with that boolean mapping. I am not 100% sure of this as of this writing, but I remember hearing that support for booleans is another difference between managed and unmanaged ODP.NET. I'm sure it's buried in the release notes or doc somewhere.
Christian Shay
Oracle

Two things you would want to try which might potentially solve the issue:
Ensure the case of the schema name, stored procedure name and the
column names in the config are the same as that in the Oracle.
Try mapping the native type to a more conformant provider type, like
the first column COL1 - map an int32 providerType to the
number(10,0) nativeDataType as enforced by your edmmapping, instead of
the Decimal that you currently have. And so forth for the other
columns (like remove the column lengths) until you do not see the error or get a different one.

I've got the same error and I think my problem is a providerType of DOUBLE or DECIMAL. But, I got one to work that has your 3 column types. Your problem is that a number(10,0) should be a providerType of "Int64".
Stored Procedure:
create or replace PROCEDURE "PROC_ESCC_FIELDS" (p_recordset OUT SYS_REFCURSOR)
AS
BEGIN
OPEN p_recordset FOR
SELECT COL1, COL2, COL3
FROM MyTable;
END PROC_ESCC_FIELDS;
This works and returns the cursor:
<oracle.manageddataaccess.client>
<version number="*">
<implicitRefCursor>
<storedProcedure schema="SERFIS" name="PROC_V_SERFIS_ESCC_FIELDS">
<refCursor name="P_RECORDSET">
<bindInfo mode="Output" />
<metadata columnOrdinal="0" columnName="COL1" providerType="Int64" allowDBNull="false" nativeDataType="Number" />
<metadata columnOrdinal="1" columnName="COL2" providerType="Date" allowDBNull="true" nativeDataType="Date" />
<metadata columnOrdinal="2" columnName="COL3" providerType="Varchar2" allowDBNull="false" nativeDataType="Varchar2" />
</refCursor>
</storedProcedure>
</implicitRefCursor>
</version>
</oracle.manageddataaccess.client>
Click here for a list of the providerType and nativeDataType, etc. ENUMS:

Related

How to override the keys in windows services .exe.config file through VSTS release definition

I am working on VSTS release task for deploying the Windows Services Project. Unfortunately, we are not creating any Build Definition for creating drop folder.
But, my client will provide drop folder for this project, what I need is “I want to override the keys of an existing .exe.config file” at release level.
For creating the Windows Services Deploy task,I followed this Windows Services Extension
For example my drop folder looks like below:
Many thanks for this reference article and It's a very useful for changing values in config file using Power Shell commands. I have doubt in from that reference link :
For Example, If had a Code like this :
<erecruit.tasks>
<tasks>
<task name="AA" taskName="AA">
<parameters>
<param key="connectionString">Server="XXXX"</param>
</parameters>
</task>
How to change this above connectionstring value?
You can use Tokenizer task in Release Management Utility tasks extension.
Install Release Management Utility tasks extension
Add Tokenizer with XPath/Regular expressions task to release definition (Specify Source filename and Configuration Json filename)
Config file sample:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="TestKey1" value="__Token1__" />
<add key="TestKey2" value="__Token2__" />
<add key="TestKey3" value="__Token3__" />
<add key="TestKey4" value="__Token4__" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
Configuration Json file (Default Environment is the environment name in release definitioin):
{
"Default Environment":{
"CustomVariables":{
"Token2":"value_from_custom2",
"Token3":"value_from_custom3"
},
"ConfigChanges":[
{
"KeyName":"/configuration/appSettings/add[#key='TestKey1']",
"Attribute":"value",
"Value":"value_from_xpath"
}
]
}
}
Then the value of TestKey1 (key) will be related to value_from_xpath and the values of TestKey2 and TestKey3 will be related to value_from_custom2 and value_from_custom3.
On the other hand, you can use release variables directly if you don’t specify Configuration Json filename.
For example, there is __TokenVariable1__ in your config file and TokenVariable1 release/environment variable in release definition, then the __TokenVariable1__ will be replaced through Tokenizer task.
A related article: Using Tokenization (Token Replacement) for Builds/Releases in vNext/TFS 2015
Update:
You also can do it through PowerShell directly.
Update configuration files using PowerShell

Trying to use DDtek Datadirect Sybase drivers as a provider for Enttiy Framework 6, can't get it configured correctly

Trying to use DDtek Datadirect Sybase drivers as a provider for Enttiy Framework 6, can't get it configured correctly..
It looks like in 3.3 there is no DDtek.Sybase.Entity,
We have a trial version of 4.2 which has the DLL, so I've installed that on.
Here is my providers section of the web.config, where I think the error lives
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory,
EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices,
EntityFramework.SqlServer" />
<provider invariantName="DDTek.Sybase.4.2" type="DDTek.Sybase.Entity.ProviderServices, DDTek.Sybase.Entity,
Version=4.2.0.0, Culture=neutral, PublicKeyToken=c84cd5c63851e072" /
</providers>
</entityFramework>
and here is my connection string
<add name="DefaultConnection" connectionString="host='XXXX.XXX';Pooling=true;Port='6000';UID='XXXXX';Password=XXXXX;Database='XXXX';Min Pool Size=5;Load Balance Timeout=30;Connection Timeout = 30000;Max Pool Size=50;Workstation ID='SPN'; Clone Connection If Needed =true; Fetch Buffer Size = 40960" providerName="DDTek.Sybase.4.2" />
The connection string, minus the providername bit works in 3.3, non EF.
Here is the error I'm getting...
The Entity Framework provider type
'DDTek.Sybase.Entity.ProviderServices, DDTek.Sybase.Entity,
Version=4.2.0.0, Culture=neutral, PublicKeyToken=c84cd5c63851e072'
registered in the application config file for the ADO.NET provider
with invariant name 'DDTek.Sybase.4.2' could not be loaded. Make sure
that the assembly-qualified name is used and that the assembly is
available to the running application. See
http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Looking at more documentation I changed the name to DDTek.Sybase (default) instead of DDTek.Sybase.4.2 (recommended fro multiple versions installed (which there are, but only one supports EF)
and this is the error I get instead
The Entity Framework provider type
'DDTek.Sybase.Entity.ProviderServices, DDTek.Sybase.Entity,
Version=4.2.0.0, Culture=neutral, PublicKeyToken=c84cd5c63851e072'
registered in the application config file for the ADO.NET provider
with invariant name 'DDTek.Sybase' could not be loaded. Make sure that
the assembly-qualified name is used and that the assembly is available
to the running application. See
http://go.microsoft.com/fwlink/?LinkId=260882 for more information.
Has anyone successfully set this up using the Progress/DataDirect drivers?
I'm 100% noob to Entity Framework, so no idea is too small, or unappreicated
The DataDirect Drivers do not support EF 6.0 as they previously told me, it
only supports 5.0.
So I converted it to work with MSDB, in like 10 min (Most of which was commenting out bits of Sybase + ddtek stuff)
The new connectionstring looked like this
<add name="DefaultConnectionMSold" connectionString="Data Source=XXXXXXXXX;Initial Catalog=my_project;Integrated Security=True" providerName="System.Data.SqlClient"/>

Can CodeFluent Generate a FileTable in SQLServer

I am trying to use a FileTable for attachments in a CodeFluent application on SQLServer 2014, but can't seem to get CFE to generate the proper SQL (CREATE TABLE .... AS FileTable).
Does anyone know how this can be defined in the model?
No, CodeFluent Entities doesn't generate FileTable. You can create it in a SQL script and add the script in your solution: SQL Server Producer - Custom scripts
However you can use FileTable to store the blobs. There are 2 ways to use FileTables:
Using the file system API: The FileTable is accessible as a classic folder so you can use the filesystem binary service
<configuration>
<configSections>
<section name="Sample"type="CodeFluent.Runtime.CodeFluentConfigurationSectionHandler, CodeFluent.Runtime" />
</configSections>
<Sample binaryServicesTypeName="filesystem" fileSystemBlobStorageRootPath="path to file table" />
</configuration>
Using T-SQL: this method is not supported out of the box by CodeFluent Entities. However you can support them by creating a class that inherits from CodeFluent.Runtime.BinaryServices.BaseBinaryLargeObject and override methods such as ProtectedSave, PersistenceLoad, PersistenceDelete, GetOutputStream, GetInputStream. Then you can declare you binary service in the configuration file:
<configuration>
<configSections>
<section name="Sample" type="CodeFluent.Runtime.CodeFluentConfigurationSectionHandler, CodeFluent.Runtime" />
</configSections>
<Sample binaryServicesTypeName="Sample.FileTableBinaryServices, Sample" />
</configuration>

Azure EF Code First Migration Initializer

I am just messing with Azure, and I can't seem to get my Db to work. I am following what it says here: https://www.windowsazure.com/en-us/develop/net/tutorials/web-site-with-sql-database/ and I updated my web.config to have this:
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<contexts>
<context type="DownloadThis.Models.DownloadThisDb, DownloadThisDb">
<databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion">
<parameters>
<parameter value="DownloadThisDb_DatabasePublish" />
</parameters>
</databaseInitializer>
</context>
</contexts>
</entityFramework>
As is shown in the example, but I keep getting this error:
Format of the initialization string does not conform to specification
starting at index 0.
I have triple checked my connectionString, so that isn't it - any ideas?
Assuming that you're publishing with the VS2012 publish wizard, I've run into the same issue. If you choose to have the publishing wizard enable code first migrations instead of manually wiring them up in your code, then you need to provide a connection string in the publish settings. Your normal connection string is not used to run the migrations, this new connection string is used for this purpose only. This is nice because you can specify an account that has elevated privileges for performing your migrations, however, your app won't run under this user context. The problem is that the wizard doesn't make the need to specify this connection string very obvious. When you don't supply this, you end up with a null migration connection string and you spend a lot of time trying to figure out what's wrong with your normal connection strings.
Let's say that your context class is named FooContext. By convention, you'll have a connection string in your web.config named FooContext. When you enable code migrations via this wizard, the wizard will create a second connection string named FooContext_DatabasePublish that will only be used for running your code first migrations.
This blog post on MSDN explains this process in some detail.
I think you're missing a . in your type string:
<databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion">
The red rectangle over the code makes it hard to read...
If that doest fix it, post a comment and I'll work up a sample to match yours and see if I can get it to work...
[UPDATED 2012-08-15]
OK - I think I know what's going on here... You mentioned "I updated my web.config to have this:" and showed your XML. When I ran through the tutorial, I did NOT have to enter ANY extra XML into my web.config. During the publishing process, the XML was added for me automagically by Visual Studio's deployment process and it all "just worked".
Here's your solution:
Go back to the original web.config file without these updates, and try publishing again.
For reference, here are the <entityFramework> sections from my two web.config files, first from my project, second from my hosted service (I got that by connecting to the running site via FTP and downloading it). The VS project is called 11964172 after the SO record number for this post:
local web.config file settings
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
</entityFramework>
deployed web.config file settings
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<contexts>
<context type="_11963331.Models.ToDoDb, 11963331">
<databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[_11963331.Models.ToDoDb, 11963331], [_11963331.Migrations.Configuration, 11963331]], EntityFramework, PublicKeyToken=b77a5c561934e089">
<parameters>
<parameter value="_11963331.Models.ToDoDb_DatabasePublish" />
</parameters>
</databaseInitializer>
</context>
</contexts>
</entityFramework>
I guess that explains why they took a picture of the web.config file changes instead of actually providing the code to type in :-)
See this question. If you leave the deployment connection string as "Remote connection string", and check the "Execute Code First Migrations" box, you will get this exception as the migration connection string, DownloadThisDb_DatabasePublish will not be defined properly. Either specify a real connection string instead of leaving the connection string box blank in the deployment wizard, or define a connection string named DownloadThisDb_DatabasePublish in your Azure site configuration.

Using XmlLogFormatter with the RollingFlatFileTraceListener in Enterprise Library

I'm trying to use the RollingFlatFileTraceListener to provide rolling logs in my app along side the XmlLogFormatter so that the logs are in an XML format, however the app no longer seems to be logging anything.
<listeners>
<clear />
<add name="Rolling Flat File Trace Listener" type="Microsoft.Practices.EnterpriseLibrary.Logging.TraceListeners.RollingFlatFileTraceListener, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
listenerDataType="Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.RollingFlatFileTraceListenerData, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
fileName="C:\Inetpub\logs\rolling.log" rollFileExistsBehavior="Increment" header="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" footer="~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" formatter="Error Formatter"
rollSizeKB="12499" maxArchivedFiles="3200" traceOutputOptions="None" timeStampPattern="yyyy-MM-dd" rollInterval="Midnight" />
</listeners>
<formatters>
<clear />
<add type="Microsoft.Practices.EnterpriseLibrary.Logging.Formatters.XmlLogFormatter, Microsoft.Practices.EnterpriseLibrary.Logging, Version=5.0.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" template="Timestamp: {timestamp(local)}
Message: {message}
Category: {category}
Severity: {severity}
Title:{title}
Machine: {machine}
Extended Properties: {dictionary({key} - {value}
)}" name="Error Formatter" />
</formatters>
Since the application isn't hard faulting, I can't see any errors to diagnose, yet I know that I should see some trace logs by now.
Update:
Current progress is that I've been able to use the RollingFlatFileTraceListnerData with the TextFormatter, making use of the template to specify XML. The two items that don't work as of yet are
The file has no XML declaration
The file has no root element, instead it has many root elements
Any thoughts on how to tack that on to the start and end of the file?
The out of the box trace listeners do not support a file header or file footer concept. As you've seen, it basically just appends to the file. Even if you used the .NET Framework System.Diagnostics.XmlWriterTraceListener it only writes XML fragments and not well formed XML documents.
One way to achieve what you want would be to create a separate process that modifies the archived files to be well formed after they have been rolled. The downside of that approach is that the active log file is not well formed.
If that is a concern then you will probably have to create a custom trace listener to do what you want. Instead of simply appending to the log file you could overwrite the XML document's closing tag (e.g. ) with the latest LogEntry and the closing tag.
Another interesting approach from the article Efficient Techniques for Modifying Large XML Files is to create a well formed XML document that includes the document with XML fragments. E.g.
<?xml version="1.0"?>
<!DOCTYPE logfile [
<!ENTITY events
SYSTEM "XMLFile1.xml">
]>
<logfile>
&events;
</logfile>