EF DbMigration Sql update not running from embedded resource - entity-framework

Using Entity Framework 6 automated migrations, I'm trying to execute SQL from an embedded resource file using SqlResource. The following script doesn't work correctly - it seems to update the column to an empty string. It does work correctly if I run the script directly in SSMS.
UPDATE [EmailTemplates]
SET Html = 'xyz'
WHERE [Type] = 'ConfirmEmail'
If I do something simple like this it works:
ALTER TABLE EmailTemplates ADD SomeColumn nvarchar null
The "Html" column is of type nvarchar(max) null. Any ideas?

Related

Getting Mapping error in OLE DB Destination when use SQL Command under Data Access Mode

I am working SSIS integration using Visual Studio 2017. I have tested 'Data Access Mode' Table Or View which did work. Now I need to filter data and I am trying to use 'Data Access Mode' SQL Command and getting Mapping issue in OLE DB Destination Editor.
In Destination Data outsource, I use OLE DB Destination and under 'Component Properties' SQL Command I type following script
INSERT INTO User_Filtered
(UserGUID
,IdNum
,FirstName
,LastName
,Email
,PostCode)
VALUES
(?,?,?,?,?,?)
In mapping getting error
error
error at user dataflow [ole db destination] no column information was returned by the SQL Command
Under the OLD DB Source I typed following script under the SQL Command dataview, which seems fine
SELECT u.*
FROM [AnotherServer].[dbo].[Users] AS u
where [email] IS NOT NULL AND [org] IS NOT NULL
In the OLE DB Destination you only need to use a SELECT statement with the columns that will be inserted into, not an INSERT statement. After this you can map the columns on the Mappings page.

How to avoid quotes around table name in Laravel Illuminate Firebird

I am creating project with Laravel Illuminate that connects to existing Firebird database using jacquestvanzuydam project. The problem is that Firebird doesn't use quotes around table and field names, but my present configuration tries to add quotes around table names in each select that it creates automatically.
How to configure Laravel or Illuminate to create SQL statements without quotes?
try to write table name like it named in your database. in your model.
protected $table = 'TABLE_NAME';
i had that problem and solved it by written table name in uppercase

SignalR hub not working with existing tables

In the begining I have given service broker enable status to database on MSSQL 2008. I have two tables with same fields. First one is existing table. Other is created new by me. Hub is not working with first existing table, but works fine with other table which we create new.
Our select statement is basic and we have used only select field like 'select field1,field2 from Table1 where field2=1'.
I am using C#.
What kind of problem can be in this issue, how can we solve?
I have found solution. SignalR wants table scheame name in sql statement. Default scheme name is dbo and our sql or stored procedure include dbo. Like:
'Select field1,field2 from dbo.Table1 where field2=1'.

The type of column conflit with the type of other columns specified in the UNPIVOT list

In SQL Server 2005, I built a trigger that contains a SQL statement that unpivot's some data. Somewhat similar to the following simple example: http://sqlfiddle.com/#!3/cdc1b/1/0. Let's say that the table the trigger is built on is "table1" and it's set run after updates.
Within SSMS whenever I update "table1" everything works fine. Unfortunately, whenever I update "table1" in a proprietary application (which I don't have the source code to), it fails with the message "The type of column conflit with the type of other columns specified in the UNPIVOT list".
After doing a bit of searching I added COLLATE DATABASE_DEFAULT to my cast's in the view without any luck. It was a bit of a long shot because the collation all matched whenever I queried INFORMATION_SCHEMA.COLUMNS.
I then changed the casts from VARCHAR to CHAR and it worked without issue. For obvious reasons, I'd rather use VARCHAR. What is different between a SSMS and application connection? I assume the application isn't using a connection property that SSMS uses.
PS: The database is a bit funky because it does not use NULLs and uses CHAR instead of VARCHAR.

Two procedures with same name & select types but EF complains about incompatible data reader

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.