Entitiy Framework migration with EF in multiple projects - entity-framework

Currently I trying to separate my data model into a different project in the same solution, with code first. If I only have one project with EF( 6.1.3 ) installed, migration ( Enable-Migration, Add-Migration ) work as intended.
But as I add an other project and install EF packet, if i try Enable-Migration, I've got this error:
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:713 char:27
+ $toolsPath = Join-Path <<<< $installPath tools
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:780 char:73
+ $utilityAssembly = [System.Reflection.Assembly]::LoadFrom((Join-Path <<<< $ToolsPath EntityFramework.PowerShell.Utility.dll))
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
You cannot call a method on a null-valued expression.
At C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:781 char:50
+ $dispatcher = $utilityAssembly.CreateInstance <<<< (
+ CategoryInfo : InvalidOperation: (CreateInstance:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\projects\IMS 2\packages\EntityFramework.6.1.3\tools\EntityFramework.psm1:810 char:19
+ (Join-Path <<<< $runner.ToolsPath EntityFramework.PowerShell.dll),
+ CategoryInfo : InvalidData: (:) [Join-Path], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.JoinPathCommand
EF seems to work fine in both of the projects. Reinstalling EF to either or both of the projects did not solve it. Any solution in mind?
EDIT: I started a new solution with 3 projects, 1. for the basecontext( public class BaseContext<TContext> : DbContext where TContext : DbContext ... ), 2. for base classes, and 3. for creating a context based on base context and the classes. If i put ef in only one then migrtation works, or at least tells me thet it can't find a context, but if i install it into more then one, then it's producing the error again.

I found the same problem today and I had to uninstall the EF and install again.
PM> Uninstall-Package EntityFramework -Force
PM> Install-Package EntityFramework -Pre

Ok, solved it, the problem was not EF, or VS2015, but my Windows 7, since it come with PowerShell 2, but EF or VS required PowerShell 3 to work properly. After updating to it the errors was gone.
Then i run ito this bug: https://connect.microsoft.com/VisualStudio/feedback/details/1302181/add-migration-bug what is currently under review.
It seems like that it's caused by some configuration bug in the VS2015 RC release. Rolled back to VS13 with powershell 2, reinstalled the related nuget packages, and it's working fine now.

Related

Publish-Module fails with NuGet.Build.Tasks.Pack.targets(198,5) error : Index was outside the bounds of the array

I've upgraded to dotnet sdk version 3.1 and am trying to publish my powershell module. I am using powershell 5.1.
I run the command:
Publish-Module -Path "C:\sources\myModules\InstallationUtils\" -NuGetApiKey "xxxxxxx" -Repository internal.packages.org"
and get the error:
[C:\Users\xxxxxx\AppData\Local\Temp\469d7c83-6e1a-4366-b948-6a415b0279be\Temp.csproj]
Successfully created package
'C:\Users\xxxxxx\AppData\Local\Temp\158464074\myModules\InstallationUtils\InstallationUtils.1.4.8.nupkg'.
C:\Program Files\dotnet\sdk\3.1.201\Sdks\NuGet.Build.Tasks.Pack\build\NuGet.Build.Tasks.Pack.targets(198,5): error :
Index was outside the bounds of the array.
[C:\Users\xxxxxx\AppData\Local\Temp\469d7c83-6e1a-4366-b948-6a415b0279be\Temp.csproj]
'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.1\PSModule.psm1:10944 char:17
+ ... Publish-PSArtifactUtility #PublishPSArtifactUtility_Param ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException
+ FullyQualifiedErrorId : FailedToCreateCompressedModule,Publish-PSArtifactUtility
Is anyone have similar issues and managed to fix it?
thanks
I have a work around, which involves replacing the old version of version nuget.exe in
C:\Users\xxxxx\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\
with the latest version of nuget.exe .
I found the work around on SQLDBAWithABeard but I am hoping that there is a better solution than this?

Is there any solution for enable-migrations Command Not foundError for Visual Studio 2019?

I was following a tutorial about the asp.net-mvc . I have been stuck in enable-migrations nuget package manager
I was first haunted by the enable-migrations cmd not found error so for that purpose I followed from the following link : Package Manager Console Enable-Migrations CommandNotFoundException only in a specific VS project
enable-migrations : Cannot bind argument to parameter 'Path' because it is null.
At line:1 char:1
+ enable-migrations
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Enable-Migrations], ParameterBindingValid
ationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Enable-Migra
tions
I did my best to find but did not found any answer on this . Can someone please help me on this matter ?
In order to enable the migrations with code first, a database must exist, try and build your application, add some data to the tables, re-build the application and try again

Powershell fails to load DLL because manifest is missing

These statements:
[Environment]::Is64BitProcess
[Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
Generate:
True
Exception calling "LoadFile" with "1" argument(s): The module was expected to contain an assembly manifest. (Exception from HRESULT: 0x80131018)
At C:\GitRepo\PowerShellScripts\ApiDllTest.ps1:11 char:1
+ [Reflection.Assembly]::LoadFile("C:\MvxAPI\MvxSockx64.dll")
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : BadImageFormatException
From a PowerShell program I've written, I am trying to send transactions to the ERP system (Infor's M3) via a DLL for APIs. The DLL is provided by the manufacture. Since I am not a system admin but just a nerd supporting the ERP system, I'm clueless as to what I'm doing and have gotten this far with Google but can't get any further. Your suggestions will be greatly appreciated.

Getting error while exporting azure db using powershell

Followed Export SQL database example using link :
https://learn.microsoft.com/en-us/azure/sql-database/sql-database-export-powershell#export-sql-database-example
Getting below error:
New-AzureRmSqlDatabaseExport : ResourceNotFound: The Resource 'Microsoft.Sql/servers/XXX.database.windows.net/databases/[DBNAME]' under resource group 'Default-SQL-SoutheastAsia' was
not found.
At [FilePath]\sample.ps1:24 char:18
+ $exportRequest = New-AzureRmSqlDatabaseExport –ResourceGroupName $ResourceGroupN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmSqlDatabaseExport], CloudException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.NewAzureSqlDatabaseExport
Get-AzureRmSqlDatabaseImportExportStatus : Cannot bind argument to parameter 'OperationStatusLink' because it is null.
At [FilePath]\sample.ps1:30 char:63
+ Get-AzureRmSqlDatabaseImportExportStatus -OperationStatusLink $exportRequest.Ope ...
+ CategoryInfo : InvalidData: (:) [Get-AzureRmSqlDatabaseImportExportStatus], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.Azure.Commands.Sql.ImportExport.Cmdlet.GetAzureSqlDatabaseImportExportStatus
Any help?
I had this same issue today, actually. I think if you change your server name to not use the fully-qualified name, that might do it. So, just use "xxxxx."
At least that's what worked for me.
You need to verify that your Automation account has latest modules imported and are up to date (AzureRM.Automation – AzureRM.Profile – AzureRM.Sql) atleast to Version: 2.5.0. If modules show a different version, i.e. 1.0.3 then:
navigate to assets in the automation account, select modules and click on
Update Azure Modules
.
Wait for the modules to get updated it normally takes a few minutes

"Method Not found" error when calling GetElementsbyClassName

I created a PowerShell automation script and I gave it to my friend when he run it, it said
Method invocation failed because [mshtml.HTMLBodyClass] does not contain a method
named 'getElementsByClassName'.
At C:\Users\עמית\Documents\asaf.ps1:22 char:3
+ $a=$docs.body.getElementsByClassName("FadeOut-Scroll")
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
why is that happened?
We both have IE11, .net 4.5, Visual studio, but I have that function and he not.
And it looks like here in his computer the IE console have the function:
but PowerShell does not:
How to update PowerShell?
Found after alot of time:
the missing want microsoft core xml