I am using VS2012 and trying to run a code I have received from a colleague (who happens to use VS2013). He is using EF (v 6.1.3) Code-First New Database approach.
Now I am trying to enable the migrations to create the database, but Package Manager Console is unable to identify Enable-Migrations code.
Below is the error I receive (please click the image to enlarge)
I have installed EF Tools for VS2012, but that does't resolve the issue. Even Microsoft tells that it can only resolve EF Code-First Existing Database problems.
I don't know if I have to rollback Microsoft.NETCore.Platforms v1.1.0 to a previous version.
Any help on this is appreciated.
Edit
Error tells that I need a newer Nuget version, but VS2012 doesn't support Nuget v2.12
Related
I'm writing a new web API using .net core 2.2 and I connected an existing database using entity framework. but I keep getting an error saying above when I try to add a controller to the existing model using Scaffold new item.
here are the commands I used
Install-Package Microsoft.EntityFrameworkCore.SqlServer
Install-Package Microsoft.EntityFrameworkCore.Tools
Install-Package Microsoft.VisualStudio.Web.CodeGeneration.Design
Scaffold-DbContext to reverse engineer and create the EF model based on my existing database.
but keeps getting below error
"There was an error running the selected code generator: ' Failed to update dependency information for the project. Please restore the project and try again.'
I tried everything I could think of and I even gets the same error when I tries to add an empty controller also
I met this issue and found nothing wrong in my project.
After deleting the bin and obj folder, this issue is gone.
i had the same error
then i uninstalled all packages and reinstall them again throught nuget
i don't no why but it worked for me
It was due to a mismatch between .netCore version and EntityFrameworkCore version.
Edit
I uninstalled the EFCore and installed a parallel versiion for .net core
Ex
.netCore 2.0.9
EFCore 2.2.4
I just migrated to RC2 from RC1 and having a really hard time getting the ef commands and migrations to work.
I've read several other questions and have ran into the problem that's getting described in this link as a known issue.
The problem is that if I follow the instructions and create a brand new console application (.core) I'm still getting the following message:
This preview of Entity Framework tools does not support targeting class library projects in ASP.NET Core and .NET Core applications. See http://go.microsoft.com/fwlink/?LinkId=798221 for details and workarounds.
What am I doing wrong? Do I need to revert to rc1?
How did you do this migration ? I ask because in my case everything works time - as for now.
In my case I have removed all RC1 components first and then I have installed new RC2 components...
Next I have created new APS project using new Visual Studio Templates to get correct references and just moved my code to this new project.
Of course it's few things which I had to update in my code, but everything works fine for me including ef commands and migrations.
As you can read in ASP.NET Core installation guide
Before you start
Remove all previous versions of .NET Core from your system by using Add/Remove programs.
You need RC1 setup file to uninstall this component - if you do not have it, check StackOverflow - you can find link to download missing files.
Try follow the docs:
ASP.NET Migration
Migrating from ASP.NET 5 RC1 to ASP.NET
Core
Migrating from DNX to .NET Core CLI
ASP.NET 5 RC1 apps were based on the .NET Execution Environment (DNX)
and made use of DNX specific features. ASP.NET Core RC2 is based on
.NET Core, so you must first migrate your application to the new .NET
Core project model. See Migrating from DNX to .NET Core CLI for more
information.
Hope this help you :)
I have already visited those questions and problem solving links:
Entity Framework 6 + SQLite
Visual Studio 2013 say me Entity framework that the provider of SQLite is not found
http://entityframework.codeplex.com/wikipage?title=Rebuilding%20EF%20providers%20for%20EF6
I downloaded and installed the 1.0.92.0 SQLite Release Package from here http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki
I create a new project (class library) in visual studio 2013.
Through NuGet I add System.Data.SQLite (which on itself also adds Core, EF6 and LINQ), EF is also installed.
I create the new ADO.NET Entity Data Model, I generate from the DB, select my DB (testing connection - ok), I go to "Which version of Entity Framework do you want to use?" and I have only the option "6" which is unavailable and it says:
Your project references the latest version of EF, however, an EF
database provider compatible with this version could not be found for
you data connection.
From what I have read, 1.0.92.0 should work with EF6 (even from 1.0.91.0)
I have done somé testing, and the SQLite support for the EF Tools appear to be completely broken, due to an incomplete implementation of the EF6 provider, which is also not installed in GAC. I would file an issue with the System.Data.SQLite developers
I have been looking at how to produce a downgrade in EF 4.3.1 Migrations, and all I have found is only about scripting (like this EF 4.3 Migration - how to produce a downgrade script?)
To upgrade my user's production database I call the method MigrateDatabaseToLatestVersion<TContext, TMigrationsConfiguration>
upon application startup, so I make sure that all users have the same database schema after they install a new version of my app. I don't need to run any scripts on the client side once the migrations are configured.
What happens if I want to downgrade to a different version? It seems quite obvious that this method only moves Up until it reaches the latest migration... is there something like MigrateDatabaseToVersion<TContext, TMigrationsConfiguration, DbMigration> where the DbMigration object is the target migration?
Can I avoid running a SQL script if I want to downgrade a production database?
Thanks guys!
You could use the migrate.exe tool which comes with EF to go to specific migrations.
Migrate.exe MyApp.exe /startupConfigurationFile=”MyApp.exe.config” /targetMigration=”myTargetMigration”
Docs can be found at: http://msdn.microsoft.com/en-us/data/jj618307.aspx
Edit: How to use a connection string
Migrate.exe whereYourMigrationsAre.dll /connectionString=”Data Source=localhost;Initial Catalog=blah;whatever else you want to set” /connectionProviderName=”System.Data.SqlClient”
I am working on a system which scaffolds a migration from inside our code using ToolingFacade.
The system worked fine in entity framework 4.3.1. After the Upgrade to 5.0 I see that the correct entity framework version is loaded when starting out tool, however when I call the scaffold method I get the following exception:
Could not load type 'System.Data.Entity.Migrations.Design.ToolingFacade+ScaffoldRunner'
from assembly 'EntityFramework, Version=4.1.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089'.
Does anyone know why calling a method in entity framework 5.0 requires an older version dll?
I ran into this issue recently when using EF6. Visual Studio required me to re-install EntityFramework via the Package Manage console to get things working again. Note that when I did so, the console output suggested that it had no idea that EF was installed before; somehow the association had been lost. Perhaps this is why the tooling assembly or assemblies weren't being loaded.
In any case, reinstalling the package via the console (and a restart of Visual Studio) solved the problem for me.