TYPO3 object storage table does not exist - (tx_extbase_persistence_objectstorage) - typo3

I recently upgraded a relatively old System TYPO3 4.7 => 6.2.
I changed alot of namespaces/imports etc. and fixed stuff here and there. After the system was stable I made some changes in the extension builder and added some new fields.
I had to change some code in some files that threw errors but after that I was able to successfully save in the extension builder.
It added the correct classes,attributes and actions but now the system shows me this error:
1247602160: Table 'keepins_upgrade.tx_extbase_persistence_objectstorage' doesn't exist
Usually this error is related to models that are mapped incorrectly in the typoscript file but this seems different.. any suggestions?

Shot from the hip: you have one or more properties in your domain model which is annotated incorrectly - so it is read as a 1:1 relation to ObjectStorage, not a 1:n to a collection of another object. Or, less likely given your previous version, you've annotated a setter method or controller action so it requires an instance of ObjectStorage, but neglected to add PHPDOC that defines the true expected child type or is somehow else invalid or not connected to the right property.

Related

Filereference extbase versus Core

I am confused because I figured out, that there are 2 different FileReference classes inside TYPO3. One of them is from the Core and the other one is from Extbase.
The one from the core has function like delete(), but this delete is not implemented yet. I cannot find any function for deleting the FileReference.
If I use update in my extension from the repository, the image will be added not replaced by the new one.
I would like to understand how I can add, delete and fetch files to/from ext_file_reference in a simple way.
Does anybody have a solution or a hint?
It's unclear from your question what you are trying to do.
If you want to replaces files, you do that on the File Object itself, not the references. But note, that this replaces the file for all references. There is a replaceFile() function on the ResourceStorage object of the file.
If you want to replace a file in a Property, you have to detach one file and attach the other. Every Property that holds FileReferences is an ObjectStorage, and as such comes with attach() and detach() methods to do that.
let me try to explain it in more details. I try to replace an image on a page with another one, but without modifying the image at all. Also the new image is already stored under fileadmin. I would need a new filereference and to replace the old one in the sys_file_reference.
So attach and detach would be the goodsolutions, but are not working with extbase filereference. For that I need a \TYPO3\CMS\Extbase\Persistence\ObjectStorage object. I tried "\TYPO3\CMS\Extbase\Persistence\ObjectStorage<\HGA\Hgarecipes\Domain\Model\FileReference>" but it creates an error "Cannot cast object of type "TYPO3\CMS\Extbase\Persistence\ObjectStorage" to string". So finally I am looking for a sulution to add and delete images from sys_file_reference under extbase. I found many pleople which are looking for something, but no solution. Alo if I use the objectstorage I have not longer access to the originalResource of the filereference.
With other words, to create a entry in the sys_file_reference with a given filepath and delete this entry if not longer needed.
On the other hand I want to understand why extbase needs a own filereference.

EF Core Second level ThenInclude missworks

Assume having these models first:
Method that has one OriginalCode
OriginalCode that has many Mutants
Mutant that has many ParseSubTrees
Now when querying on Method I want the other being loaded. So I have the following:
Method targetMethod = dBContext.Methods
.Include(me => me.OriginalCode)
.ThenInclude(oc => oc.Mutants)
.FirstOrDefault(me => me.Id == id);
and the next step is to include additionally the ParseSubTree. But the thing is that I can't access it. See the following Image:
the problem is "mu is a list instead of being an object reference"!
Where is my mistake!
TG.
This is a known Intellisense issue with the ThenInclude overload for collection type navigation properties, tracked by the Completion missing members of lambda parameter in fault tolerance case #8237 Roslyn GitHub issue.
Until it gets fixed, simply type the name of the property and it will compile successfully and work as expected.
.ThenInclude(mu => mu.ParseSubTrees)
Update: Now it's even specifically mentioned in the Including multiple levels
section of the EF Core documentation:
Note
Current versions of Visual Studio offer incorrect code completion options and can cause correct expressions to be flagged with syntax errors when using the ThenInclude method after a collection navigation property. This is a symptom of an IntelliSense bug tracked at https://github.com/dotnet/roslyn/issues/8237. It is safe to ignore these spurious syntax errors as long as the code is correct and can be compiled successfully.
In my case there was a conflict between the namespaces System.Data.Entity and Microsoft.EntityFrameworkCore. Just delete the first using line.

EF broken after update database. A namespace cannot contain members such as fields or methods

I have researched this topic and pulled up a couple of hits that I thought might have helped me. So far I am still pulling out my hair over here because everything was fine until I added a field to a table in Azure and then tried to update my model.
Here's a short sitrep of what the problems have been and what I have done to solve them.
Problem 1
Compiling transformation: Metadata file 'C:\Program Files\VS2013\Common7\Tools..\IDE\Microsoft.Data.Entity.Design.dll' could not be found
Compiling transformation: Metadata file 'C:\Program Files\VS2013\Common7\Tools..\IDE\EntityFramework.dll' could not be found
I solved the problem by changing my global environment variable in advanced system properties to the correct location of these files, which in my case was : F:\Program Files (x86)\Common7\IDE
This is probably due to the fact that I just installed VS 2013 ultimate on my F drive; however, I have been developing on it successfully now for a week and never had a problem until now.
After this I run into problem 2:
Problem 2
A namespace cannot directly contain members such as fields or methods C:\Users\Adrian.Campos\Documents\Visual Studio 2013\Projects\ConsoleApplication2\ConsoleApplication2\Model1.cs 1 1 ConsoleApplication2
As you can see the problem is arising from my Model1.cs class. My .edmx file is named model1 (fyi)
I found some links that weren't of help to me since my error is coming from a different source than that of the links.
VS2012: My Entity Framework model doesn´t get included to my project output using InstallShield
A namespace cannot directly contain members such as fields or methods.
A namespace cannot directly contain members... + Type or namespace definition, or end-of-file expected errors
That last link seemed the most promising; however, it did not fix my problem. What I do not understand is how in the world did everything just blow up after I updated my model?
Has anyone else experienced this and fixed it?

EntitySet could not be found

I'm working on an MVC site using EF4 as my data source. I've had no problems with other projects with EF4 until today. I'm getting an error stating EntitySet name Entities.Sites could not be found. I have another EDMX file for another dataset that is set up nearly the same (with different entity names) and it works fine when I try to run a LINQ query against it.
My EDMX has 2 tables (site and page) with a 1 to many association from the site to page table. Everything compiles fine, but in runtime, it's almost like the datamodel fails on every property list population. I do have Lazy Loading enabled (It's a .NET 4 project).
I stepped through the code on the designer class and it fails when it gets to a call like this
if((_Pages == null))
{
_Pages = base.CreateObjectSet<Page>("Pages");
}
I have not altered the code in the designer.cs. I'm at a major wall with this.
Any ideas what I could be doing wrong?
Try renaming your entity Page to something else, like EntityPage (for example) to see if this resolved it. As stated by #Yakimych this could simply be a case of Namespace clashing

CA: Suppress results from generated code not working in VS2010 beta 2

I'm trying to run codeanalysis on an assembly that contains an entity model (edmx file). In project properties I have checked the "Suppress results from generated code" option, but I am still getting a lot of CA errors pertaining to the auto-generated EF code.
Has anyone experienced this? And is there a work-around?
Just put the attribute on your class definition.
But how to do it, since your file can get overridden any time. Use a separate file, since all generated classes are partial classes. Open a separate file, and write something like:
[GeneratedCode("EntityModelCodeGenerator", "4.0.0.0")]
public partial class YourEntitiesContextName : ObjectContext
{
}
This will skip code analysis on your particular generated class. StyleCop for instance is more smart and doesn't touch files that have .designer/.generated part in their name or regions that have generated word in their name.
Well, "Suppress results from generated code" really means "Don't look at types with GeneratedCodeAttribute". EF's code generator hasn't added this, historically (though I've suggested it to the team). But you can add it if you use custom T4.