Why tries CSLA 4.5 to load Entity Framework 4.3.1?

Why tries CSLA 4.5 to load Entity Framework 4.3.1?

Old forum URL: forums.lhotka.net/forums/t/11715.aspx


BGrojer posted on Wednesday, November 21, 2012

In our project we run into a MEF Composition error caused by CSLA 4.5 (no error with the CSLA 4.2 Version) that basicaly tells us that we Entity Framework 4.3.1 is missing.

But in our client component (.NET4.0) Entiy Framework should not be required alt all. The same happens in our Server application (.NET 4.5) with Entity Framework 5.0 referenced (no 4.3.1 Version here ).

if we replace the CSLA.dll again with the old 4.2 Version everything works fine again.

Thank you.

JonnyBee replied on Wednesday, November 21, 2012

CSLA 4.5 does reference EF 4.3 but it is actually MEF that tries to load all classes in the assemblies and inspect them for Import/Export attributes.

For next version I have refactored EF dependecies into separate assemblies and can then also support both EF4 and EF5 (and EF6 when available).

Workaround: For your MEF Composition to work I would change the initialization of the MEF container to only add your own assemblies - not any of the CSLA assemblies. If you add *.dll to the container then ALL files in the assemblies must load correctly for MEF to inspect the classes and methods.  CSLA Framework has absolutely NO attributes targeted for MEF.

CSLA 4.2 only referene the standard EF included wIth .NET 4.5.  Sometime after 4.2 we added support for DbContextManager which was introduced in  EF 4.3 for Model First development.

BGrojer replied on Wednesday, November 21, 2012

Works for me! Fine thank you.

Its the same story with the AsyncTargetingPack. Its not a good idea to load always Version 4 (e.g. if you reference a .net 4 project with CSLA 4 in .net 4.5 project you run into the issue that you need to add a reference to the AsyncTargetingPack (with Version 4) in the executable.

Copyright (c) Marimer LLC