TYPO3 Extension Builder Integrate of existing table - typo3

I tried to integrate an existing table to my extension. The problem is that the content of the table isn't taken over.
I created a new model with the name of the existing table and named the properties according to the existing column names. I also implemented the corresponding getters and setters of the properties.
Extension
The name of the existing table is tx_institutsseminarverwaltung_domain_model_event.

How are you trying to "consume" or access the data from the other table in your extension?
Do you have a repository for the existing table (maybe there is already an existing repository, that you can reuse)?
See german typo3 board mapping existing tables and SO thread TYPO3 / How to make repository from existing table fe_users?
This question is most likely a duplicate of this question

The solution for this issues is:
First get the Typo3 query settings
$querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings');
Set RespectStoragePage to false
$querySettings->setRespectStoragePage(FALSE);
Fetch your repository
$theRepository = $this->objectManager->get('TYPO3\\institutsseminarverwaltung\\Domain\\Repository\\EventRepository');
And set the query settings to your repository.
$theRepository->setDefaultQuerySettings($querySettings);

Related

Extbase looking for wrong table

I'm using TYPO3 7.4.0 and I'm learning to build extensions in extbase & fluid.
I have a vendor prefix in my table names. I create three tables for my extensions. When I go in the backend and add entities in the list view on the resource folder I created, it works without any problems. When I go to the Frontend to view the index action of my entity it looks for a table without the vendor prefix in it's name. Does anyone know what that means? I create the tables in the "ext_tables.sql". I have no table mapping defined. I don't know where to change which tables extbase is looking for.
By default Extbase looks for table using schema tx_extkey_domain_model_modelname, so for Animal model in zoo ext it will be tx_zoo_domain_model_animal. (extkey without underscore if any!)
If you used other schema (like vendor name within table name) you need to use mapping. I.e. create file ext_typoscript_setup.txt in main folder of your ext and use this:
config.tx_extbase{
persistence{
classes{
Vendor\Zoo\Domain\Model\Animal {
mapping {
tableName = tx_your_own_name
}
}
}
}
}
BTW: it's best idea to keep the original naming schema. Other thing is that creating extensions manually can be tricky - at least for beginners, install Extension Builder ext to fast kickstart new extensions just with click-click way.

Web API Entity Framework error - Item with idenity already exists in the metadata collection

I am experimenting with a Web API 2 project in Visual Studio 2012. I used the code first from existing DB option with EF6 to select one table and one view. I then tried to create a controller for the simple table using the profile for Web API 2 OData. The scaffolding of the controller fails telling me that "the item with identity 'Client Last Reveiwed On' already exists in the metadata collection". The problem is not only am I sure that field is unique for this project but that field is part of the view and not the table. Below is the model generated for the simple table (t_Client) that I was trying to create the controller for. As you can see the offending column is not part of the class. I will add below the definition for the column that VS/EF doesn't like which is in the class for the view.
Any ideas why this won't work?
Partial Public Class t_Client
<Key>
<DatabaseGenerated(DatabaseGeneratedOption.None)>
Public Property ClientID As Integer
<Required>
<StringLength(255)>
Public Property ClientName As String
Public Property isActive As Boolean
End Class
Here is the column that is defined in a separate view.
<Column("Client Last Reviewed On", TypeName:="date")>
Public Property Client_Last_Reviewed_On As Date?
I am not sure which of these steps fixed the issue but here are some notes on the topic.
Removing references to the model based on the SQL view eliminated errors.
I went into SQL and updated the view to contain a row number column.
Even with the row number column, EF tagged multiple columns as the key.
I manually edited the model to make the row number column the key.
I also had to update a cast the data type of a few columns in the SQL view to match reality, mainly bigint that was really just integer.
My guess is the fix was the well defined key.

TYPO3 Extension Error: Cannot create empty instance of the class

My FE plugin created using extension builder shows me the following error :
Cannot create empty instance of the class "TYPO3\CMS\Extbase\Persistence\ObjectStorage" because it does not implement the TYPO3\CMS\Extbase\DomainObject\DomainObjectInterface.
What does it mean and how do I resolve it?
TYPO3 version 6.1.0
My Domain Object named Subject has relations Category_Id m:n relation and Location_Id 1:n relation . I did not map these two to any table during the creation of the extension.
How do I mention this in the extension that these relations are related to certain tables (Category_table and Location_table)and are to be looked in their respective domain model objects to retrieve data ?
The problem is a little confusing, I hope I made myself clear
Thank You
You need to set up the relation within the TCA.
Make sure to clear the cache and to remove the typo3temp/Cache/.
Then you will need to annotate your model properly such that extbase can resolve the reference.
Remember: TCA for core and annotation for extbase

How to update only one table for model from database with Entity Framework?

I have a model generated from db with Entity Framework. When I have any change in database, I update model from database to get the change in model. But this update is applied to all entities (tables) included in model.
Now I add a new column in a table Tab1. I don't want to update model from database as some other changes that I don't want to include in model. I can add the new property in model for entity Tab1 manually. then it caused mapping error.
So I need to update Model.Store for the table to include the new column. It means I want to update model only for Tab1.
How can I do this?
The EDMX file is an XML file that is a combination of 3 different parts that make up the whole thing. If you right-click on your EDMX file and choose "Open with... XML Editor" you'll see the 3 different sections:
<edmx:ConceptualModels>
<edmx:StorageModels>
<edmx:Mappings>
These sections can be edited manually, at your own risk! :-)
That way you can modify only what you need to.
Note that it's also possible to generate CSDL, SSDL & MSL files rather than having them embedded in the binary file, by changing the "Meta Artifact Processing" property of your model to "Copy to Output Directory".
If you don't want to do this manually, there's the Huagati DBML/EDMX tool, it is free and you can download it from huagati official site or from visual studio gallery, which is a Visual Studio plugin that allows you to select what changes need to be done.
I use following (Conditional) trick. This could be done only when no Table depends on the table which you want to update.
Delete the table which needs to be updated.
Right click on Model and select 'Update Model From Database'. The Table would be shown in the tab 'Add'. Select this table and Update the model.
Precaution : If other existing tables have changes in them, EF would update these changes as well.
There is way of doing it automatically.
right click edmx file > update model from data base > Refresh tab > Tables > select the table(you want to update) and press finish that's it.

Cannot add Currency field to Entity after Importing

A custom entity was created in our DEV environment. It originally had a Currency field, but we decided to remove it and use a Float field for simplicity. After exporting the solution and importing it into QA for the first time, I can no longer add a Currency field to the entity in QA (and the "leftover" transactioncurrencyid column in DEV did not get migrated to QA).
The main problem is that I cannot remove the transactioncurrencyid column and now my Filtered views are different between DEV and QA which causes our SharePoint BCS process that relies on Entity Framework to fail.
Is there any way to completely remove a currency field without recreating the entity?
Plan B: Is there a way to restore a past copy of the entity (prior to removing the currency) from a backup and merge it into our presently broken version?
Plan C: any other ideas (convert EF to use Stored Procs, etc)?
Thanks!
Export the entity from Dev into QA again. CRM will see that a column has been added, and will add it to the entity in QA.
Edit 1
So this is an unmanaged solution in QA? You should be able to just add the field to the entity in QA through the Customize Solution interface.
The MSFT approved solution involved manually removing:
the ExchangeRate column from the Base table (e.g. alter...drop column exchangerate)
the rows referencing the attribute's GUID in the system tables: Attribute, localizedlabel, AttributeIds (e.g. delete from tbl where AttributeId = guid)
altering the entity's View to remove the ExchangeRate column (not the Filtered)
Finding the GUID in Step 2 was done by opening the ExchangeRate field in CRM and pressing F11 to extract the AttributeID from the querystring.