I am trying to import stored procedure into the entity model using database first approach and import fails due to the following warning. I am using Visual Studio 2015 update3
Error 6005: The funtion 'ar_get_contact_name' has a return data type 'varchar' that is currently not supported for the target Entity Framework version. The function was excluded.
Error 6046: Unable to generate function import return type of the store function 'ar_get_contact_name'. The function will be ignored and the function import will not be generated.
Table and SP as follows
create table "entityframework".ar_contact
(
contact_code char(10) not null primary key,
name char(80) not null
);
CREATE PROCEDURE 'entityframework'.ar_get_contact_name (
cont_code LIKE ar_contact.contact_code)
RETURNING
VARCHAR(50);
DEFINE cont_name VARCHAR(255);
SELECT
ar_contact.name
INTO
cont_name
FROM
ar_contact
WHERE
cont_code = contact_code;
RETURN cont_name;
END PROCEDURE
Is there any workaround for this?
Truly Informix do not have a good story with Entity Framework (EF) Support yet.
Right now for .net application to use EF functionality they have to use DB2 driver connection to Informix using DRDA protocol.
While using the DB2 EF driver connecting to Informix database, many of the functionality work ok (but not all).
Certain functionalities are different at database level for DB2 and Informix.
The return value of store procedures and functions are one of such difference; very likely you may be getting into this difference.
Related
I'm seeking some advice.
I've migrated a database from SQL Server to Aurora PostgreSQL using AWS DMS. In most of the tables in SQL Server, the primary keys are a uniqueidentifier (GUID). When migrated to Postgres these columns are converted to VARCHAR(36). This seems to be as expected, per the AWS DMS documentation.
In our .NET application, we use Entity Framework 6, which I have added a new dbContext to use the npgsql provider. Note that we are still keeping existing SQL Server EF6 providers. Essentially, the application will use both SQL Server and PostgreSQL. This is all hooked up fine.
Where I run into some issues is when my Postgres context is making fetches to the PostgreSQL database, it encounters a lot of errors
Npgsql.PostgresException: 42883: operator does not exist: character varying = uuid
I understand the issue, where the application using EF makes a fetch by Id (GUID), and the Postgres table has an Id that is VARCHAR type...
My feeling is the problem is not on the application or EF side, rather the column on the table should be something like a UUID. Which I can do, on post migration, I can simply alter the column to become a UUID type, but is this the way, and will it resolve my issues? I also feel like this can't be a unique case I'm dealing with; seems like a common issue for anyone also migrating a .NET app from SQL Server to PostgreSQL...
I look forward to hearing some of your ideas, comments, thoughts on this. Thanks in advance.
It seems that this migration procedure is not quite up to the task, as a GUID (which is Microsoft's confusing term for UUID) should be migrated to uuid. Not only would you save 21 bytes of storage space per row, but you also wouldn't have this problem.
It seems that your application is comparing a uuid value with one of the migrated varchars:
WHERE uniqueidentifier = UUID '87595807-3157-4a81-ac89-3e09e83c0c0a'
You have to add an explicit cast, like the error message says:
WHERE uniqueidentifier = CAST (UUID '87595807-3157-4a81-ac89-3e09e83c0c0a' AS text)
You would cast to text, not to varchar, because there is no equality operator for varchar. varchar is coerced to text when you compare it, because the storage for these types is identical.
I am trying to change the service based database in my project to SQLite. I am using EF database first approach but the EF does not generate every model from database. Eventhough foreign keys are set it does not generate the connections and also returns an error:
> Error 6005: The data type '' is currently not supported for the target Entity Framework version; the column 'Id' in the table 'main.Comments' was excluded.
It does so with every table that has an Id column (integer, primary key).
How can I fix this?
Thanks
I have a application which uses Firebird (Version 2.5) database. I wanted to trigger one of the table entry to another database table which is in SQL Server 2008 R2. When I commit I am getting this following error
ErrorCode: 335544569 (ErrorMessage: Dynamic SQL Error SQL error code = -104).
Code:
CREATE TRIGGER "trig_INV"
FOR "INVA"
ACTIVE
AFTER UPDATE
POSITION 100
AS
BEGIN
IF ((updating) AND ((old.cold <> new.cold))) THEN
BEGIN
INSERT INTO 192.168.17.206/1043: [RBT].[dbo].[N_Inv]([COLA], [COLB], [COLC], [COLD], [COLD], [COLE])
SELECT FIRST 1
"COLA", "COLB", "COLC", "COLD", "COLE"
FROM "INVA"
ORDER BY COLA DESC
END
I am not sure firebird trigger allow to push records to a SQL Server database. It will be great if anyone has tried such and provide some reference. Thanks in advance.
You get that error because the syntax you're using doesn't exist in Firebird. Firebird has no support to connect to other database systems than Firebird (in theory you could write a provider that allows connecting to other databases systems, but as far as I know, none exist in reality).
If you want to synchronize to a different database system, you will either need to write a UDF or UDR (the replacement of UDFs introduced in Firebird 3) to do this for you, or a custom application that provides synchronization, or use third-party software to do this (for example, SymmetricDS).
I'm using Elastic search to store large amount of data to make it searchable, but for configuration items I'm still using HSQL DB.
Is it possible to eliminate HSQL DB completely and use my existing Elastic search in combination with Crate DB?
Things I have tried:
tried connecting to my existing Elastic search using Crate driver and Crate client but I got an exception No handler found for action "crate_sql". Does that mean I cannot use my existing ES and have to use inbuilt ES in crateDB??
After connecting to crateDB elastic search (and not my existing ES). I was able to get connection using CrateDriver and run SQL queries. But in one of module I'm creating table using below command:
create table some_table_name
(
id VARCHAR(256),
userName VARCHAR(256),
fieldName VARCHAR(256),
primary key (id),
unique (userName, fieldName)
);
...but then I got an exception:
io.crate.action.sql.SQLActionException: line 1:28: no viable alternative at input 'VARCHAR'
Does that mean I cannot write create table query using SQL syntax and SQL data types?
I know it will work if I use string data type instead of varchar, but I don't want to change all those queries now.
1)
No you cannot use existing ES nodes together with Crate. The whole SQL analyzer/planner/execution layer is done server side, not client side. In fact the crate clients are rather dumb.
2)
You'll have to change the types and also remove / change anything that isn't supported by crate. For example defaults or unique constraints aren't supported (up to 0.39 - in the future support might be added)
In your case the varchar type isn't valid in Crate, instead you'll have to use "string".
See Data Types Documentation for a list of supported data types.
I have two same procedures in two DB, by same I mean:
Same name
Same parameters name & type
End with a select returning same columns types & names (If I put a SELECT ... INTO table it generates the exactly same table).
The only thing which differs is the code building the sql query for the final select.
If I use EF on Database 1 it works as intended, but if I run the code on Database 2 it ends on error:
The data reader is incompatible with the specified 'Ctx.Procedure_Result'. A member of the type, 'FooId', does not have a corresponding column in the data reader with the same name.
I'm using:
Entity Framework 4.2
Visual Studio 2010
Sql Server 2008 R2
I don't have enough knowledge of EF internals to understand why this is happening.
My idea is that there must be some columns types/names sniffing mecanism which doesn't sniff the same stuff.
Edit 1:
The procedure doesn't "return" a table type it just "select" some rows.
This select result is mapped to a ComplexType in the EDMX.
Feel free to ask for more details.
My fault, as suggested I traced the EF queries with SQL Server Profiler.
In fact EF was using NULL in an optional parameter which destroyed the sql query inside the procedure ('select ... ' + NULL => NULL).
With a NULL query the procedure select no column at all and it crashes the EF data reader.