Jenssegers/mongodo relations not working after upgrading to Laravel 5.3 - mongodb

After upgrading to Laravel 5.3, querying hybrid relations relations are throwing an error.
FatalErrorException in Builder.php line 613:
Call to a member function all() on array
I am using HybridRelations trait, and trying to query a Moloquent model from an Eloquent Model
$user->store()->first();
Here $user is an Eloquent Model and has a store(Moloquent). While querying this relation, I am getting this error.
Any help?

Alpha Laravel 5.3 support is available on release >= 3.1.x (currently 3.1.0-alpha)
So you can simply upgrade dependency version to 3.1.0-alpha and run composer update

Related

Add options when moving from NetCore 2 Newtonsoft JSON to the new JSON API in NetCore 3

I recently upgraded my Entity Framework Core project from DotNet Core 2.2 to 3.1.
I am using newtonsoft json, but I am wondering if I still need these two lines that are causing the errors. Here are those two lines:
services.AddMvc()
.AddJsonOptions(
options =>
{
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
});
And here is the error:
'JsonOptions' does not contain a definition for 'SerializerSettings' and no accessible extension method
'SerializerSettings' accepting a first argument of type 'JsonOptions'
could be found
Does the new Microsoft JSON library have anything that would ignore reference loops and null values like Newtonsoft JSON does?
This is a known limitation of System.Text.Json and this feature might be addressed in .net 5 which is slated for Nov 2020 :
Reference : https://github.com/dotnet/corefx/issues/38579 and https://github.com/dotnet/corefx/issues/41002
Currently the workaround is to use Newtonsoft JSON instead . To use Newtonsoft.Json in an ASP.NET Core 3.0 MVC project :
Install the Microsoft.AspNetCore.Mvc.NewtonsoftJson package.
Update Startup.ConfigureServices to call AddNewtonsoftJson and set settings :
services.AddMvc()
.AddNewtonsoftJson(options => {
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
});

Upgrading EF in pregenerated views: The default target Entity Framework version requires the edmx schema version 2 or lower

I have pre-generated views following the templates of the next link:
http://blogs.msdn.com/b/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx
I need to improve to Entity Framework 5.0 but if I replace the schemas as following:
stringBuilder.Replace("http://schemas.microsoft.com/ado/2008/09/mapping/cs", "http://schemas.microsoft.com/ado/2009/11/mapping/cs");
stringBuilder.Replace("http://schemas.microsoft.com/ado/2008/09/edm", "http://schemas.microsoft.com/ado/2009/11/edm");
stringBuilder.Replace("http://schemas.microsoft.com/ado/2008/10/edmx","http://schemas.microsoft.com/ado/2009/11/edmx");
stringBuilder.Replace("http://schemas.microsoft.com/ado/2009/02/edm/ssdl", "http://schemas.microsoft.com/ado/2009/11/edm/ssdl");
I still having the following error:
Warning 3 The default target Entity Framework version requires the
edmx schema version 2.0.0.0 or lower. The specified schema is version
3.0.0.0. To avoid this warning specify the target Entity Framework version explicitly. You can do this by using the EdmGen.exe
command-line tool with the targetVersion option, or by including the
targetEntityFrameworkVersion parameter when calling the GenerateCode
method.
Any idea of how to solve this issue using templates?
What is the equivalent of adding /targetversion:4.5 to EdmGen using templates?
I found the solution to my problem...
There was a leading help in the following link:
http://blog.3d-logic.com/2012/05/28/entity-framework-code-first-and-pre-generated-views/
moozzyk says:
August 5, 2012 at 11:51 pm
I did see this when using Visual Studio 2012 and EF5. For now the workaround is to edit the >template. Change the line 70 from:
var errors = viewGenerator.GenerateViews(mappingItemCollection, writer).ToList();
to:
var errors = viewGenerator.GenerateViews(mappingItemCollection, writer, >EntityFrameworkVersions.Version3).ToList();
Sorry for the inconvenience.
I had to slighlty modify my code in a similar way, from:
IList errors = viewGenerator.GenerateViews(mappingItems, writer);
To:
IList errors = viewGenerator.GenerateViews(mappingItems, writer, EntityFrameworkVersions.Version3);
After that, no warning nor error whatsoever.

Fatal error: Class 'Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle' not found

I'm trying to install mongodb since 3 days but each time, I had a different error message until I fix some of them and I could install mongodb for my Symfony 2.1.4 installation. So now I have this error message:
"Fatal error: Class 'Doctrine\Bundle\MongoDBBundle\DoctrineMongoDBBundle' not found"
I couldn't find any solution to solve it.
For information in my composer.json I added these lines:
"doctrine/mongodb-odm": "*",
"doctrine/mongodb-odm-bundle": "v2.0.1"
and it creates 3 folders in the Doctrine namespace:
doctrine/mongodb
doctrine/mongodb-odm
doctrine/mongodb-odm-bundle
Why is this occurring?
For Symfony 2.1, you'll need to use version 3.0 of the Doctrine ODM MongoDB Bundle.
"doctrine/mongodb-odm": "1.0.*#dev",
"doctrine/mongodb-odm-bundle": "3.0.*#dev"
The reason the bundle you installed could not be found was because it was under a different namespace, being Symfony\Bundle\DoctrineMongoDBBundle\DoctrineMongoDBBundle for Symfony 2.0

MEF - Migration from .NET 3.5 to .NET 4.0

I've got an easy sample from the internet that works fine in the .NET 3.5 framework using System.ComponentModel.Composition.dll version v2.0.50727
I've changed the project definition and changed the target to .NET 4.0 and it works perfect.
When I replace the v2.0.50727 version of the above .dll to the latest version which is v4.0.30319 I get an error that complains during the composition of the container. The code where it break is as follows:
private void LoadPlugins() {
var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
var container = new CompositionContainer(catalog);
container.ExportsChanging += new EventHandler(container_ExportsChanging);
var batch = new CompositionBatch();
batch.AddPart(this);
container.Compose(batch); // throws Exception
}
And the exception is the following:
System.ComponentModel.Composition.ChangeRejectedException was unhandled
Message=The composition remains unchanged. The changes were rejected because of the following error(s): The composition produced a single composition error. The root cause is provided below. Review the CompositionException.Errors property for more detailed information.
1) More than one export was found that matches the constraint '((exportDefinition.ContractName == "MefTutorial.IPlugin") AndAlso (exportDefinition.Metadata.ContainsKey("ExportTypeIdentity") AndAlso "MefTutorial.IPlugin".Equals(exportDefinition.Metadata.get_Item("ExportTypeIdentity"))))'.
Resulting in: Cannot set import 'MefTutorial.PluginConsumer._myPlugins (ContractName="MefTutorial.IPlugin")' on part 'MefTutorial.PluginConsumer'.
Element: MefTutorial.PluginConsumer._myPlugins (ContractName="MefTutorial.IPlugin") --> MefTutorial.PluginConsumer
What do I need to do to migrate to the .NET 4.0 concerning MEF?
Could it be that another project still references the .net 3.5 version? The error message says that there are two exports of type IPlugin, which I'm quite certain of means that finds both the 3.5 and 4.0 version of the dll.
Check that only the 4.0 version of MefTutorial is referenced and/or present.
OK, I found the problem. Apparently in the previous version the notation was as mentioned in my previous comment, but in the new .NET 4.0 version the syntax for import should be:
code>
[ImportMany(typeof(IPlugin))]
internal List _myPlugins { get; set; }
Notice the use of List and ImportMany instead of IList and Import.

generate-migrations-diff failing with Zend framework

I am trying to generate a migration script using Doctrine with Zend Framework. I am getting the following:
$ php doctrine.php generate-migrations-diff
$ PHP Fatal error: Cannot redeclare class Avo_Model_AccessType in
$ tmp/fromprfx_doctrine_tmp_dirs/AccessType.php on line 16
I can successfully build the models form the yaml file. I am using Zend Framework 1.10.5 and Doctrine 1.2.2 I think the issue might be with the autoloader and the fact that Zend Autoloads the classes that doctrine is trying to re-create.
I've got the same error today. The problem was that in bootstrap I preloaded all models with
Doctrine_Core::loadModels($options['models_path']);
So, I just removed that line and it helped.