Entity Framework 4.3 Migration Exception when Update-Database - entity-framework

After upgrading from EF 4.2 and Migration to EF 4.3 and enabling migration,restarting Visual studio and everything , whenever I try to call Update-Database/Add-Migration I get this:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException:
The parameter is incorrect. (Exception from HRESULT: 0x80070057
(E_INVALIDARG))
--- End of inner exception stack trace ---
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[]
byrefModifiers, Int32 culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[]
namedParams)
at System.Management.Automation.ComMethod.InvokeMethod(PSMethod method, Object[] arguments)
Update-Database : Exception has been thrown by the target of an invocation.
At line:1 char:1
+ update-database
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : OperationStopped: (Exception has b... an invocation.:String) [Update-Database], RuntimeException
+ FullyQualifiedErrorId : Exception has been thrown by the target of an invocation.,Update-Database
I tried cleaning the whole project , deleting ef and migration and packages folder and doing it from the beginning and still same error !
Anyone facing the same error? Or have a solution for this?

In case you have context and migration in separate projects, you need to use -StartupProjectName "YourProject" option of add-migration and update-database
The same error was in 4.3 beta. I encountered it in 4.3 release as well.

Instead of using the Powershell commands, you can control the migration via code, and then tell it where your assembly and context are:
var configuration = new DbMigrationsConfiguration() {
MigrationsAssembly = typeof(YourMigrations).Assembly,
ContextType = typeof(YourContext)
};
Then you can either script it out or auto-run it by using the DbMigrator class:
var migrator = new DbMigrator(configuration);
var scripter = new MigratorScriptingDecorator(migrator);
string script = scripter.ScriptUpdate(null, null);

Related

entity framework core migrations do not work with class library, yet?

I have an asp.net core project 'Api' with target:
<TargetFramework>net471</TargetFramework>
That project references another class library project 'Repository' with target:
<TargetFramework>netstandard1.4</TargetFramework>
The 'Api' project has this configured:
services
.AddEntityFrameworkSqlServer()
.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"),
b => b.MigrationsAssembly("Repository"))
)
.AddScoped(p => new ApplicationDbContext(p.GetService<DbContextOptions<ApplicationDbContext>>()));
When I am in the PMConsole I enter:
Add-Migration Initial
then I get this error:
Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
add-migration : Exception calling "Substring" with "1" argument(s): "StartIndex cannot be less than zero.
Parameter name: startIndex"
At line:1 char:1
+ add-migration
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Add-Migration], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentOutOfRangeException,Add-Migration
What do I wrong?
The EF Core commands only work for startup projects, i.e. something that can actually run, as opposed to a class library. This is because the context is created via dependency injection, which can only occur during runtime. A workaround is to create an implementation of IDesignTimeDbContextFactory in your class library. When the commands see your implementation, that factory will then be used to instantiate the context.
public class MyContextFactory : IDesignTimeDbContextFactory<MyContext>
{
public MyContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<MyContext>();
optionsBuilder.UseSqlServer("[connection string here]");
return new MyContext(optionsBuilder.Options);
}
}
For more information, see the documentation.

Catel with Xamarin.Forms

I can't get Xamarin.Forms and Catel work together.
I saw this sample but it seems it's out of date.
When I download Catel via NuGet, i get different issues for different versions:
v5.1:
Compile-time exception:
Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'Obsolete, Version=4.2.4.0, Culture=neutral, PublicKeyToken=1ca091877d12ca03'. Perhaps it doesn't exist in the Mono for Android profile?
v5.0:
Runtime exception (when creating new App();):
Could not load signature of Catel.MVVM.IViewModelFactory:CreateViewModel due to: Could not resolve type with token 01000061 (from typeref, class/assembly System.ComponentModel.IDataErrorInfo, Catel.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null) assembly:Catel.Core, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null type:System.ComponentModel.IDataErrorInfo member:<none>
v4.5.*
Using ViewModelBase:
Runtime exception when creating Application object:
System.TypeLoadException: Could not resolve type with token 01000097 (from typeref, class/assembly System.Reflection.BindingFlags, Catel.Core, Version=4.5.4.0, Culture=neutral, PublicKeyToken=null)
My implementation of IViewModel:
Ok, MainPage loading, binding works, Constructor gets right services via parameters, but, for example, when I call '_uiVisualizerService.Show( subPageViewModel );' from command, it throws 'InvalidCastException'. Last line in Catel log before exception: Injecting properties into type 'SubPage' after construction. But SubPage and SubPageViewModel are absolutely empty.
Details:
---> System.InvalidCastException: Specified cast is not valid.
at Catel.Services.UIVisualizerService+<ShowAsync>d__9.MoveNext () [0x00096]
in C:\CI_WS\Ws\97969\Source\Catel\src\Catel.MVVM\Catel.MVVM.Xamarin.Forms\Services\UIVisualizerService.cs:151
at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskCanceledExceptions) [0x00011]
in <183b200ee49746d48fc781625979428e>:0
at System.Threading.Tasks.Task'1[TResult].GetResultCore (System.Boolean waitCompletionNotification) [0x0002b]
in <183b200ee49746d48fc781625979428e>:0
at System.Threading.Tasks.Task'1[TResult].get_Result () [0x0000f]
in <183b200ee49746d48fc781625979428e>:0
at Catel.Services.UIVisualizerService.Show (Catel.MVVM.IViewModel viewModel, System.EventHandler``1[TEventArgs] completedProc) [0x00000]
in C:\CI_WS\Ws\97969\Source\Catel\src\Catel.MVVM\Catel.MVVM.Xamarin.Forms\Services\UIVisualizerService.cs:125
at XamarinFormsCatel.ViewModels.MainPageViewModel.OnGo () [0x00015]
in C:\!Work\Test\XamarinFormsCatel\XamarinFormsCatel\XamarinFormsCatel\XamarinFormsCatel\ViewModels\MainPageViewModel.cs:34
at Xamarin.Forms.Command+<>c__DisplayClass3_0.<.ctor>b__0 (System.Object o) [0x00000]
in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Command.cs:73
at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000]
in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Command.cs:107
at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked () [0x0000a]
in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Button.cs:121
at Xamarin.Forms.Platform.Android.AppCompat.ButtonRenderer+ButtonClickListener.OnClick (Android.Views.View v) [0x0000b]
in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.Android\AppCompat\ButtonRenderer.cs:298
at Android.Views.View+IOnClickListenerInvoker.n_OnClick_Landroid_view_View_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_v) [0x0000f]
in <71828dd8fb5f4508815e23d6996c45c2>:0
at (wrapper dynamic-method) System.Object:4c9f6786-8ab0-4bd8-bdb1-4cc7a3d7ddc7 (intptr,intptr,intptr)
-> (Inner Exception #0) System.InvalidCastException: Specified cast is not valid.
at Catel.Services.UIVisualizerService+<ShowAsync>d__9.MoveNext () [0x00096]
in C:\CI_WS\Ws\97969\Source\Catel\src\Catel.MVVM\Catel.MVVM.Xamarin.Forms\Services\UIVisualizerService.cs:151 <---
What i do:
Change defalt Catel.MVVM.dll reference in android project from MonoAndroid to portable-net45+wp8+win8+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10+UAP10. if this is not done, compilation will fail.
MainPage.xaml
<catel:ContentPage ...
xmlns:catel="clr-namespace:Catel.Windows.Controls;assembly=Catel.MVVM">
MainPageViewModel.cs
public class MainPageViewModel : ViewModelBase { }
App.cs
public class App : Catel.Xamarin.Forms.Application<Views.MainPage> { }
MainActivity.cs (Android)
public class MainActivity : Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
protected override void OnCreate( Bundle bundle )
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate( bundle );
Xamarin.Forms.Forms.Init( this, bundle );
var app = new App();
LoadApplication( app );
}
}
Windows 7, 64x.
Xamarin.Forms: 2.3.4.267
Any help very appreciated.
The team is working on improved support for Xamarin.Forms. At the moment there are no examples. The expectation is to finalize v5 support for Xamarin.Forms on this over the next few months.

How to create a LocalDB instance for NEventStore

I'm trying to use LocalDb with NEventStore but, even though I think I have set-up the database correctly, I keep getting the following exception:
NEventStore.Persistence.StorageUnavailableException: Invalid object name 'Snapshots'.
In code I configure NEventStore to use the database like this:
this.EventStore = Wireup.Init()
.LogToOutputWindow()
.UsingInMemoryPersistence()
.UsingSqlPersistence("DefaultConnection")
.WithDialect(new MsSqlDialect())
.UsingJsonSerialization()
.LogToOutputWindow()
.Build();
I have the following database connection in my web.config file:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\MyDatabase.mdf;Initial Catalog=MyDatabase;Integrated Security=True" providerName="System.Data.SqlClient" />
And using Visual Studio I've added an SqlServerDatabase (MyDatabase.mdf) to the App_Data folder of my Asp.net MVC 5 project. NEventStore seems to be able to open the database (if I remove MyDatabase.mdf from my project I get a different exception). But it seems its unable to initialize the database correctly. When I browse the database, after running into the error message, I see that no tables have been created.
What makes this extra strange is that, if this document is correct, Snapshots should be the second table made. So it seems it has no problem creating the first one.
The complete stack trace for the StorageUnavailableException
at NEventStore.Persistence.Sql.SqlDialects.PagedEnumerationCollection.OpenNextPage() in c:\TeamCity\buildAgent\work\38b1777f2112a252\src\NEventStore\Persistence\Sql\SqlDialects\PagedEnumerationCollection.cs:line 200
at NEventStore.Persistence.Sql.SqlDialects.PagedEnumerationCollection.MoveToNextRecord() in c:\TeamCity\buildAgent\work\38b1777f2112a252\src\NEventStore\Persistence\Sql\SqlDialects\PagedEnumerationCollection.cs:line 146
at NEventStore.Persistence.Sql.SqlDialects.PagedEnumerationCollection.System.Collections.IEnumerator.MoveNext() in c:\TeamCity\buildAgent\work\38b1777f2112a252\src\NEventStore\Persistence\Sql\SqlDialects\PagedEnumerationCollection.cs:line 70
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at NEventStore.Persistence.Sql.SqlPersistenceEngine.GetSnapshot(String bucketId, String streamId, Int32 maxRevision) in c:\TeamCity\buildAgent\work\38b1777f2112a252\src\NEventStore\Persistence\Sql\SqlPersistenceEngine.cs:line 225
at NEventStore.Persistence.PipelineHooksAwarePersistanceDecorator.GetSnapshot(String bucketId, String streamId, Int32 maxRevision) in c:\TeamCity\buildAgent\work\38b1777f2112a252\src\NEventStore\Persistence\PipelineHooksAwarePersistanceDecorator.cs:line 45
at NEventStore.AccessSnapshotsExtensions.GetSnapshot(IAccessSnapshots accessSnapshots, String bucketId, Guid streamId, Int32 maxRevision) in c:\TeamCity\buildAgent\work\38b1777f2112a252\src\NEventStore\AccessSnapshotsExtensions.cs:line 49
at CommonDomain.Persistence.EventStore.EventStoreRepository.GetSnapshot(String bucketId, Guid id, Int32 version) in c:\TeamCity\buildAgent\work\38b1777f2112a252\src\NEventStore\CommonDomain\Persistence\EventStore\EventStoreRepository.cs:line 147
at CommonDomain.Persistence.EventStore.EventStoreRepository.GetById[TAggregate](String bucketId, Guid id, Int32 versionToLoad) in c:\TeamCity\buildAgent\work\38b1777f2112a252\src\NEventStore\CommonDomain\Persistence\EventStore\EventStoreRepository.cs:line 54
at CommonDomain.Persistence.EventStore.EventStoreRepository.GetById[TAggregate](Guid id, Int32 versionToLoad) in c:\TeamCity\buildAgent\work\38b1777f2112a252\src\NEventStore\CommonDomain\Persistence\EventStore\EventStoreRepository.cs:line 44
at CapraLibraShop.DataModel.Repositories.UserAggregateRepository.UserWithEmailExists(EmailAddress emailAddress) in D:\Projects\C#\CapraLibraShop\CapraLibraShop.DataModel\Repositories\UserAggregateRepository.cs:line 22
at CapraLibraShop.Controllers.AccountController.Register() in D:\Projects\C#\CapraLibraShop\CapraLibraShop\Controllers\AccountController.cs:line 55
at lambda_method(Closure , ControllerBase , Object[] )
at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
I literally found the answer two minutes after looking. But since I had a hard time Googling this answer I think it would be nice to place the answer here, instead of deleting the question.
I forgot to initialize the storage engine. I overlooked it because of the fluid syntax. The correct way to let NEventStore initialize the database is by including the InitializeStorageEngine method after you have selected the database type:
this.EventStore = Wireup.Init()
.LogToOutputWindow()
.UsingInMemoryPersistence()
.UsingSqlPersistence("DefaultConnection")
.WithDialect(new MsSqlDialect())
.InitializeStorageEngine() // The oh so important line!
.UsingJsonSerialization()
.LogToOutputWindow()
.Build();

"An unexpected error ocurred" CRM2015 OnPremise Plugins

For 2 weeks we have been experiencing a small totally random issue with plugins in CRM 2015 OnPremise. When we make an upload, randomly and without much sense (at least according to analyze all code does not) plugins are throwing us the following exception:
The Web Service plug-in failed in OrganizationId:
fb2630bc-8dc1-e411-80be-bae05bad392c; SdkMessageProcessingStepId:
d2713f4e-51b7-e411-80b8-527d00dcf108; EntityName: new_serviciobase;
Stage: 30; MessageName: Create; AssemblyName:
Microsoft.Crm.Extensibility.InternalOperationPlugin,
Microsoft.Crm.ObjectModel, Version=7.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35; ClassName:
Microsoft.Crm.Extensibility.InternalOperationPlugin; Exception:
Unhandled Exception: System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation.
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[]
arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object
obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj,
BindingFlags invokeAttr, Binder binder, Object[] parameters,
CultureInfo culture)
at System.Web.Services.Protocols.LogicalMethodInfo.Invoke(Object
target, Object[] values)
at
Microsoft.Crm.Extensibility.InternalOperationPlugin.Execute(IServiceProvider
serviceProvider)
at
Microsoft.Crm.Extensibility.V5PluginProxyStep.ExecuteInternal(PipelineExecutionContext
context)
at
Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext
context)
Inner Exception: System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation.
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type,
Boolean publicOnly, Boolean noCheck, Boolean& canBeCached,
RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly,
Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly,
Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at
Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.InitializePlugin[T](IOrganizationContext
context, StepDescription stepDescription, SecureConfigurationCache
stepSecureConfigurationCache, Type type)
at Microsoft.Crm.Extensibility.V5PluginProxyStep..ctor(Guid stepId,
SecureConfigurationCache stepSecureConfigurationCache, CrmEventLog
eventLog, IOrganizationContext context)
at Microsoft.Crm.Extensibility.PluginStep..ctor(Guid stepId,
SecureConfigurationCache stepSecureConfigurationCache, CrmEventLog
eventLog, IOrganizationContext context)
at
Microsoft.Crm.Extensibility.PipelineStepFactory.CreateInstance(Guid
stepId, IOrganizationContext context)
at Microsoft.Crm.Caching.PipelineStepCacheLoader.LoadCacheData(Guid
key, ExecutionContext context)
at
Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key,
IOrganizationContext context)
at
Microsoft.Crm.Caching.CrmMultiOrgCacheBase`2.CreateEntry(TKey key,
IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey
key, IOrganizationContext context)
at
Microsoft.Crm.Caching.MessageProcessorCacheLoader.GetCustomizationLevel(MessageProcessor
mp, ExecutionContext context)
at
Microsoft.Crm.Caching.MessageProcessorCacheLoader.LoadCacheData(MessageProcessorKey
key, ExecutionContext context) at
Microsoft.Crm.Caching.ObjectModelCacheLoader`2.LoadCacheData(TKey key,
IOrganizationContext context)
at Microsoft.Crm.Caching.CrmSharedMultiOrgCache`2.LookupEntry(TKey
key, IOrganizationContext context)
at
Microsoft.Crm.Extensibility.InternalMessageDispatcher.TryGetMessageProcessor(MessageProcessorKey
key, ExecutionContext context)
at
Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.IsPipelineDefined(MessageProcessorKey
key, ExecutionContext context)
at
Microsoft.Crm.Extensibility.ExtensiblePlatformMessageDispatcher.CreateWithInvocationSource(BusinessEntity
entity, Int32 invocationSource, ExecutionContext context)
at
Microsoft.Crm.BusinessEntities.BusinessProcessObject.Create(IBusinessEntity
entity, ExecutionContext context)
Inner Exception: System.IO.FileLoadException: Could not load file or
assembly ‘SCM.CRM.Core, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=369abd01f82b8d9d’ or one of its dependencies. Access is
denied.
at SCM.CRM.Plugins.Plugin..ctor(Type childClassName)
at SCM.CRM.Plugins.PLGServicioBase..ctor()
It brings a little headache because we don't understand what happened, just that sometimes fails and sometimes not ... we have a custom library registered plugins (disk) "SCM.Core.dll" to which says itself unable to access ... Any ideas?
As #Sxntk said, you need to make sure you merge any plugins with ilmerge if you are using Sandbox mode isolation mode when registering the plugin assembly.
If you have an isolation mode of 'none', make sure the assembly is in the GAC or placed in the bin\assembly folder in the CRM installation directory on the server.
Hopefully this helps.
I'm a coleague of Alexis, and now we have more details thanks to crmdiagtool:
System.IO.FileLoadException: Microsoft Dynamics CRM has experienced an error. Reference number for administrators or support: #ED0C936C: System.IO.FileLoadException: Could not load file or assembly 'SCM.CRM.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=369abd01f82b8d9d' or one of its dependencies. Access is denied.
File name: 'SCM.CRM.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=369abd01f82b8d9d'
You can do the following thing:
make sure all your referenced assemblies have "Copy Local" set to "True"
unload the project from visual studio
right click on the unloaded project and edit the csproj file
add the following lines in the csproj file right before the "Project" end tag (before last line in the document):
<Target Name="AfterResolveReferences">
<ItemGroup>
<EmbeddedResource Include="#(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'">
<LogicalName>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</LogicalName>
</EmbeddedResource>
</ItemGroup>
</Target>
add this method to the plugin class:
private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
AssemblyName assemblyName = new AssemblyName(args.Name);
string path = assemblyName.Name + ".dll";
if (assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false)
{
path = String.Format(#"{0}\{1}", assemblyName.CultureInfo, path);
}
using (Stream stream = executingAssembly.GetManifestResourceStream(path))
{
if (stream == null)
return null;
byte[] assemblyRawBytes = new byte[stream.Length];
stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length);
return Assembly.Load(assemblyRawBytes);
}
}
add the following constructor to the plugin class:
static [Constructor name]()
{
AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
}
rebuild and register your plugin
Doing this, all the referenced assemblies that are copied locally to your bin folder are packed into the main dll. The drawback is that you could end up having such a huge dll that you can not register it as a plugin.
Hope this helps,
Cheers

Ef 4.x dbcontext generator fails when executed

I have vs2010, installed Entity framework 4.3.1 from nuget, installed the EF 4.x DbContext Generator from microsoft. I create a project then try to add a new EF 4.x DbContext Generator item but the following error. Does anyone know how to resolve this?
Error 1 Running transformation:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.IO.FileNotFoundException:
Unable to locate file at
Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolvePath(String
path) at
Microsoft.VisualStudio.TextTemplating.VSHost.TextTemplatingService.ResolvePath(String
path) --- End of inner exception stack trace --- at
System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo
method, Object target, Object[] arguments, SignatureStruct& sig,
MethodAttributes methodAttributes, RuntimeType typeOwner) at
System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method,
Object target, Object[] arguments, Signature sig, MethodAttributes
methodAttributes, RuntimeType typeOwner) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture,
Boolean skipVisibilityChecks) at
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags
invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at
Microsoft.VisualStudio.TextTemplatingE78BCB29E8D7A2F9432A449161229C3F.GeneratedTextTransformation.DynamicHost.ResolvePath(String
path) at
Microsoft.VisualStudio.TextTemplatingE78BCB29E8D7A2F9432A449161229C3F.GeneratedTextTransformation.MetadataLoader.TryCreateEdmItemCollection(String
sourcePath, String[] referenceSchemas, EdmItemCollection&
edmItemCollection) at
Microsoft.VisualStudio.TextTemplatingE78BCB29E8D7A2F9432A449161229C3F.GeneratedTextTransformation.MetadataLoader.CreateEdmItemCollection(String
sourcePath, String[] referenceSchemas) at
Microsoft.VisualStudio.TextTemplatingE78BCB29E8D7A2F9432A449161229C3F.GeneratedTextTransformation.MetadataLoader.TryLoadAllMetadata(String
inputFile, MetadataWorkspace& metadataWorkspace) at
Microsoft.VisualStudio.TextTemplatingE78BCB29E8D7A2F9432A449161229C3F.GeneratedTextTransformation.TransformText()
at
Microsoft.VisualStudio.TextTemplating.TransformationRunner.RunTransformation(TemplateProcessingSession
session, String source, ITextTemplatingEngineHost host, String&
result) 1 1
Clearly its a case of PEBKAC. I hadn't created my edmx file. Once I had done this all I needed to do was right click on the model. Select "Add Code Generation item".