Linq2db issue witth linqtodb.ttinclude - c#

Hello I've have a project created with linqtodb with a database in MySQL and make an upgrade so I can work with the Windows 10, the problem grow and I've been forced to remove the linq2db and all dependencies and now when I've reinstalled and try to run the connection with the database the system give me this error:
Severity Code Description Project File Line Suppression State Error Compiling transformation: Cannot convert lambda expression to intended delegate type because some of the return types in the block are not implicitly convertible to the delegate return type ~\..\contentFiles\any\any\LinqToDB.Templates\LinqToDB.ttinclude 1012
UPDATE
I've made a clean of cache give me an error updating the entityframework aparently there's no way to installed because of this:
Error Could not install package 'MySql.Data 8.0.16'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.5', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0
Any help thanks in advance.

Taking into account that those templates work for everyone, I will suspect that somemething lead to corruption of templates in nuget cache from where they referenced. I would first recommend to clear nuget cache (check this link How to clear NuGet package cache using command line?) and reinstall linq2db packages. If issue still persist - it will be better if you will fill issue with environment/versions details.

Related

Entity Framework: Error "Cannot bind argument to parameter 'Path' " on "database-update"

I'm getting this error when I try to update my database
Update-Database : Cannot bind argument to parameter 'Path' because it
is null. At line:1 char:2
Update-Database
CategoryInfo : InvalidData: (:) [Update-Database], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Update-Database
can you point me in the right direction to solve the problem?
thank you
This bug has been reported on GitHub (see issues 1290, 1306, 1348). It was fixed (by the reporter of issue 1290) and is available in nightly builds. It was first scheduled for the 6.4.0 release (scheduled for late November/early December per this comment) but has since been moved to a 6.3.1 release. Neither milestone has a due date as of writing this.
The bug only affects EF Migrations and it only applies to using a Web Application project as the startup project (even if your entities and context are in different projects). If affects multiple commands (Enable-Migrations, Add-Migration, Update-Database, and Get-Migrations) because they call into the code that contains the bug.
If you need to use Migrations, either downgrade to version 6.2.0 or use one of the workarounds that have been identified.
If you downgrade, make sure do it to all projects that use it within the solution. If the 6.3.0 package is referenced by any project, the 6.3.0 PowerShell module will take precedence. You can use the "Manage NuGet Packages for Solution..." command from the solution node to help identify where 6.3.0 might still be installed in any projects. Once that's done, you'll need to close and reopen the project in order to load 6.2.0's PowerShell module.
Workarounds
If you want/need to use version 6.3 and you're encountering this error, there are several workarounds you can try. Here's what I've been able to put together:
Use a Console Application as the startup project.
Because the bug only affects Web application projects, the conditional branch that has causes the error is never executed. If you already have a console application with the right connection string, you can use that. If you don't, you can add a dummy project for this purpose.
Note: If your connection string includes |DataDirectory|, this won't work because it avoids specifying the --data-dir argument in order to avoid the bug.
Use a nightly build.
Although this works, it's probably a non-starter for a lot of projects because pre-release builds are generally disallowed in production. If your production release is still several months away, though, it might be an option if you're willing to proceed with the hope that a working release becomes available in time.
Add a dummy project that references a nightly build.
Similar to using a nightly build, you're referencing it in an unused project in order to load the fixed PowerShell module. You would still reference the released version in the projects used by the application.
Modify the local package in the shared cache location.
Caution: This is not a tenable solution for teams (or CI/CD environments) but it might be okay for an individual who wants to use a quick hack while waiting for the next release and doesn't mind reapplying it if the shared cache gets cleared.
If you're using PackageReference tags in your project files, assemblies are referenced in a shared cache location, usually under %USERPROFILE%\.nuget\packages. You can modify the file there as shown in issue 1290 and it will be used by all projects that use the package via PackageReference tags. If you're using packages.config you have to modify it in the packages folder and that's more likely to be lost.
I have tested all of these workarounds with successful outcomes.

Xamarin - Multi-targetting - "'System.ValueTuple`2' is declared in multiple referenced"

As soon as I try to compile code that use C# 7 tuples with multi targets (netstandard2.0 and xamarin.iOS) I got the following error:
Predefined type 'System.ValueTuple`2' is declared in multiple
referenced assemblies
It might've been added automatically as a reference from another package. Just remove that NuGet package to resolve the conflict.
uninstall-package System.ValueTuple is the command for the package manager console.
I don't know which assemblies the conflict occurred in.
However, I realized I had not myself added the ValueTuple nuget package so I explicitly did and the error went away.

Entity Framework - The migrations configuration type was not be found in the assembly

I have multiple DbContexts in a C# project and I'm trying to enable migrations. When I specify the full command, i.e.:
Enable-Migrations -ContextTypeName Models.Account.AccountDetailDbContext
A migrations folder is created, with the configuration class, but I then get a message:
Checking if the context targets an existing database...
And then
The migrations configuration type 'Portal.WebUI.Migrations.Configuration' was not be found in the assembly 'Portal.WebUI'.
Even though it has just created the file, it can't find it.
I have the correct project selected in the Package Manager Console
I have tried the command using -verbose, but it gives no additional information
If I copy the dbcontexts and classes into a new project then it all works, so it must be something in this existing project that is making the migration fail, but I can't tell what it is.
I solved this by adding EntityFrameworkCore\ before Add-Migration, i.e. the final statement was:
EntityFrameworkCore\Add-Migration
After give a name for your new migration.
I faced this problem. My solution:
Exit visual studio
Open your project again on visual studio
Rebuild solution
Then the error removed. And I can run the command.
After you run Enable-Migrations and the Configuration file is created, rebuild the project and run Enable-Migrations -Force again.
I had this problem and it was solved by changing the dropdown box at the top of the Package Manager Console to choose the correct project. You may need to maximise the width of the package manager console to see this box.
I managed to resolve this by uninstalling the EF nuget package and then reinstalling it.
I have stumbled upon this problem, and after endless hours of googling and trial and error, the solution to my specific problem was much easier.
Just make sure you have all your EF related nuget packages up to date.
I tried every answer I could find here, but what ended up working for me was: Select all EF related nuget packages
(In my case)
Microsoft.EntityFrameworkCore.SqlServer
Microsoft.EntityFrameworkCore.Tools
Microsoft.EntityFrameworkCore.Design
EntityFramework
And update them all, into their latest version (In my case)
The issue was that one of the defaults I downloaded of one of these NuGet packages, was outdated and invalid.
Another possible issue worth checking: is your project signed? As I just discovered, this problem can also eventuate if the assembly is signed with a strong name key file. Part of the EntityFramework tool kit is migrate.exe which is called during the migration process. It appears if the assembly is signed, this application can't find the configuration type.
Solution seems to be <Project> → Properties → Signing: untick "Sign the assembly", at least while performing migration tasks. Tick it back when you're done.
I also had this issue because of a spelling mistake in a namespace
I was facing the same issue. What I found was that in my project name, "-" was included as "abc-xyz". I deleted my project and recreated it as "abcxyz" and it worked. Don't rename the project—you have to rename it at every reference. In this case, first uninstall EF and rename it, then install EF again.
I have faced this problem due to version update of EF package. I have solved by reinstalling:
1.Microsoft.EntityFrameworkCore.SqlServer
2.Microsoft.EntityFrameworkCore.Tools
3.Microsoft.EntityFrameworkCore.Design
4.Microsoft.EntityFrameworkCore
The solution is to check the project reference. In my case, I have added Entity Framework and Entity Framework Core references to my project.
To Resolve this I have removed Entity Framework Reference from the project and now EF Core migration commands are working.
using Microsoft.EntityFrameworkCore.SqlServer;
using Microsoft.EntityFrameworkCore.Tools;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore;
Then:
Use EntityFramework6\ before Add-Migration for Entity Framework 6.
Like EntityFrameworkCore6\Add-Migration
In this case First, check NuGet packages
Microsoft.EntityFrameworkCore.SqlServer Microsoft.EntityFrameworkCore.Tools Microsoft.EntityFrameworkCore.Design
most probably missing one of the above packages you get an error.
if missing then install and
do migration using
Add-Migration InitialCreate

Entity Framework Import-Module : The specified module '...EntityFramework.psd1' was not loaded

Recently I decided to use Entity Framework for a personal project.
From my Visual Studio 2013 community edition and using NuGet I installed the latest version of the framework (nuget version 2.8.60318.734 and Entity Framework 6.1.3)
Everything seems to work OK I was able to perform simple CRUD operations, till I needed to update my model.
After it, of course I got the error message:
“Additional information: The model backing the 'MyContext' context has changed since
the database was created. Consider using Code First Migrations to update the database
(http://go.microsoft.com/fwlink/?LinkId=238269).”
Seems an appropriate error message, I just need to Enable-Migrations.
Switch to Package Manager Console and there was a message in bright red background
PM> Import-Module : The specified module 'D:\[MyProjects]\[ProfOfConcept]\EntityFrameworkInvalidFilepath\packages\EntityFramework.6.1.3\tools\EntityFramework.psd1' was not loaded because
no valid module file was found in any module directory.
At D:\[MyProjects]\[ProfOfConcept]\EntityFrameworkInvalidFilepath\packages\EntityFramework.6.1.3\tools\init.ps1:8 char:14
+ Import-Module <<<< (Join-Path $toolsPath EntityFramework.psd1)
+ CategoryInfo : ResourceUnavailable: (D:\[MyProjects]...yFramework.psd1:String) [Import-Module], FileNotFoundException
+ FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
Hmmmm something is wrong, I guess some needed part of the framework was not correctly installed, but let's check the file. The file was present, and the content seemed OK.
Alright let's try to reinstall it, just in case something went wrong at the first time. Using NuGet I tried to uninstall, and reinstall.
Checking Package Manager Console, again the same dreaded error!
Hmmm, let's try to do the uninstall /reinstall from the Package Manager Console. Again the same error!
After spending more time trying to Google similar problems I came across someone describing a similar problem Entity Framework with NuGet - Import-Module error in init.ps1 Tried that… no luck.
So what is really going on? In a Eureka moment I thought… hold on, what was my project path?
D:\[MyProjects]\[ProofOfConcept]\….
Could it be? Could the square brackets be the reason?
Create a copy the project to a simple path (d:\tmp\myProject) start the Visual Studio, enter Package Management Console, …. no error !
Enable-Migrations
PM> Enable-Migrations
Checking if the context targets an existing database...
Detected database created with a database initializer. Scaffolded migration '201504051040353_InitialCreate' corresponding to existing database. To use an automatic migration instead, delete the Migrations folder and re-run Enable-Migrations specifying the -EnableAutomaticMigrations parameter.
Code First Migrations enabled for project EntityFrameworkInvalidFilepath.
That's it!! The square brackets are the culprits
So the bottom line is this, if you are using Entity Framework don’t use [ ] in the path.
I recently had the same issue with NuGet not installing EF 6.1.3 properly because the EntityFramework.psd1 file wasn't being imported. Uninstalling and re-installing EF through Visual Studio didn't help.
What worked for me was to quit VS, navigate to '[Project Root Directory]\packages' and delete the EntityFramework6.1.3 directory. When you restart VS and go to the package manager console, it will let you know that there are modules missing and ask if you want to import them. When you click 'Reload' EF 6.1.3 is installed properly under the 'packages' directory.
In my case I'm using the 2015RC, which has a lot of issues with EF migrations.

Why the compilation error from Team City after adding Newtonsoft.Json?

I have a service that was sending bad DateTime data due to use of the JavascriptSerializer. I used Nuget to add Newtonsoft to the project, and utilized that. Here's the only place it's utilized in the code (old way, then new):
374
- var messageString = new JavaScriptSerializer().Serialize(messageDetails);
374
+ var messageString = Newtonsoft.Json.JsonConvert.SerializeObject(messageDetails);
Below is an error that occurs during the Team City build:
Consumer\MetricTrackingMQServiceConsumer.cs(374, 49): error CS0122: 'Newtonsoft.Json.JsonConvert' is inaccessible due to its protection level
Consumer\MetricTrackingMQServiceConsumer.cs(374, 61): error CS0117: 'Newtonsoft.Json.JsonConvert' does not contain a definition for 'SerializeObject'
The project compiles fine locally. Why is it failing in Team City?
As you're using NuGet to include the dependency here's the workflow I strongly suggest to avoid these type of issues.
Ensure that your reference to the Newtonsoft DLL is pointing at the NuGet packages folder.
Exclude the NuGet packages from source control.
Add a "Nuget Installer" type build step before your solution build step to restore all the NuGet packages referenced by the solution.
This has a number of advantages but most importantly given your current issue, it ensures that the version of the DLL referenced by your solution is available and in the correct location.
The following steps fixed this for me:
On your nuget installer step in your build: You may need to "Disable looking up packages from local machine cache"
Uninstall the newtonsoft reference via nuget in your project. Open the csproj file in a text editor and manually delete any remaining references to newtonsoft in there. Save the csproj file, reload your project
Reinstall newtonsoft via nuget
post your changes to your repository (git or whatever you have)
Rerun the teamcity build

Categories

Resources