350+ errors: The type 'blah.blah.blah' already contains a definition? - asp.net-mvc

What does this mean. Is it because I have two different .DBML files that contain the same database table?
...
Error 343 The type 'mvc.Models.Bundle' already contains a definition for 'BundleIcon' C:\inetpub\wwwroot\Models\Assets1.designer.cs 3438 17 mvc
Error 344 The type 'mvc.Models.Bundle' already contains a definition for 'isScorm' C:\inetpub\wwwroot\Models\Assets1.designer.cs 3459 15 mvc
Error 345 The type 'mvc.Models.Bundle' already contains a definition for 'scormPath' C:\inetpub\wwwroot\Models\Assets1.designer.cs 3480 17 mvc
Error 346 The type 'mvc.Models.Bundle' already contains a definition for 'CompanyID' C:\inetpub\wwwroot\Models\Assets1.designer.cs 3501 14 mvc
...

Yes, if you keep them in the same namespace this would occurr.

OK, I came across this same error when adding another Linq-to-SQL .dbml.
The more specific cause is that you can not have 2 separate .DBML's in the same namespace which reference the same table and column.
Unlike in Datasets, wherein you can have 2 separate Datasets (Dataset1.xsd and Dataset2.xsd) weach ith the same table and same columns, not so in Linq.
DataClass1.dbml with table MyTable with a column myColumn and DataClass2.dbml with table also name MyTable with a column myColumn will fail because myColumn is defined in both designer.cs files within the same namespace.
My workaround: I 'renamed' DataClass2.dbml's MyTable to MyTable_2 and myColumn to myColumn_2.
I then cursed Microsoft, deleted DataClass2.dbml and integrated the 3rd table I needed into DataClass1.dbml, along with other tables (to avoid this issue). DataClass1.dbml now has some 40 tables in it, which now causes the DataClass1.designer.cs file to have over 20,000 lines of 'auto-generated' code.
Lovely, eh.

Related

Using FireDac to update only 1 of a duplicate row (no primary key or unique field)

I have an old application I am supporting that uses a Microsoft Access database. The original table design did not add primary keys to every table. I am working on a migration program that among other things is adding and filling in a new primary key field (GUID) when needed.
This is happening in three steps:
Add a new guid field with no constraints
Fill the field with new unique guids
Add the primary key constraints
My problem is setting the unique guids when the table has duplicate rows. Here is my code to set the guids.
Query.SQL.Add('SELECT * FROM ' + TableName);
Query.Open;
while Query.Eof = false do
begin
Query.Edit;
Query.FieldByName(NewPrimaryKeyFieldName).AsGuid := TGuid.NewGuid;
Query.Post;
Query.Next;
end;
FireDac generates an update statement that contains a where clause with all the original fields/values in the row (since there is no unique field for it to use). However, because the rows are complete duplicates the statement still updates two rows.
FireDac correctly errors with this message
Update command updated [2] instead of [1] record.
I can open up the database in Access and delete the duplicate records or assign them a unique guid by editing the table. I would like my conversion tool to automatically do this.
Is there some way to work with these duplicate rows in FireDac? Either to update just one at a time, or to delete just one of them?
In my opinion there is no way to do it with just one SQL Statement.
I would do this:
1. Copy the whole table without duplicates by using a new temp table
SELECT DISTINCT * FROM <TABLENAME>
Add the Keys
Delete old table content and copy new content from new table
Notes:
The DB Should be unavailable for everyone else for that Operation
2. Make BACKUP before

Model.group(:id) throws an error "Select list is not in GROUP BY clause contains non aggregated column "id"

I am using Model.group(:category) in order to get unique records based on category field in Rails 5 application.
Table data:
id catgeory description
1 abc test
2 abc test1
3 abc test2
4 xyz test
5 xyz testabc
I want records (1,4) as a result. Therefore I am using Model.group(:category) which works fine for MYSQL whose sql_mode is " " .
Unforunately its throwing an error "SELECT list is not in GROUP BY clause and contains nonaggregated column which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by" whose sql_mode is "only_full_group_by".
whats the best way to change the query to match the mode?
Perhaps try specifying which id you want? You could use MIN(id), MAX(id) etc.
MySQL supports a non-standard extension to SQL described here. To continue using that behavior, you could change the sql_mode to TRADITIONAL in config/database.yml.

How can I move the column with the values from one table to another in rails?

I am want to move the column from one table to another.
So I've created 3 migrations:
AddNewColumnToTableTwo
MoveTheValuesFromTableOneToTableTwo
RemoveColumnFromTableOne
The 'thing' is - when I'm trying to run through all the records in the TableOne and update the TableTwo I see the error
TypeError: can't cast Columnname
P.S. Column type in both tables is hstore. Mayb this is the problem?

Talend csv to relational db tables : foreign key setting

I'm a Talend beginner and searched about this simple problem, many have posted the web about the same problem but no solution appeared...
I have a csv file with 50 fields, I want to load it into a three tables relational database with Talend. I did a tMap, everything is ok except for foreign key : I don't know how to set them.
Here is my job
Here is my tMap
I hope someone could give me the simple exact solution
Cheers
Pascal
You can do it in two Time.
(CSV) -> (tmap) -> (organisation_output)
|
subjobok
|
| (organisation_input)
| |
(CSV) -> (tmap)-> (country and adress output)
Do a INNER JOIN in the second tmap on column that have unique value for each row.
And load 'ImpID' of your organisation input in the two other output table Impid column.

Firebird Insert Distinct Data Using ZeosLib and Delphi

I'm using Zeos 7, and Delphi 2009 and want to check to see if a value is already in the database under a specific field before I post the data to the database.
Example: Field Keyword
Values of Cheese, Mouse, Trap
tblkeywordKEYWORD.Value = Cheese
What is wrong with the following? And is there a better way?
zQueryKeyword.SQL.Add('IF NOT EXISTS(Select KEYWORD from KEYWORDLIST ='''+
tblkeywordKEYWORD.Value+''')INSERT into KEYWORDLIST(KEYWORD) VALUES ('''+
tblkeywordKEYWORD.Value+'''))');
zQueryKeyword.ExecSql;
I tried using the unique constraint in IBExpert, but it gives the following error:
Invalid insert or update value(s): object columns are
constrained - no 2 table rows can have duplicate column values.
attempt to store duplicate value (visible to active transactions) in unique index "UNQ1_KEYWORDLIST".
Consider to use UPDATE OR INSERT or MERGE statements:
update or insert into KEYWORDLIST (KEYWORD) values(:KEYWORD) matching(KEYWORD)
For details check the following documents in your Firebird installation folder:
doc\sql.extensions\README.update_or_insert.txt
doc\sql.extensions\README.merge.txt

Resources