dotnet ef database update not creating tables from existing migrations in EF Core and .NET 6 - entity-framework-core

I'm trying to add tables via my existing migrations so I can work on this locally on another machine.
I'm running the dotnet ef database update command in the terminal, but it doesn't create any of the tables - it only gets as far as:
Build started...
Build succeeded.
info: Microsoft.EntityFrameworkCore.Infrastructure[10403]
Entity Framework Core 6.0.7 initialized 'PingContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer:6.0.7' with options: None
and that's the end of the command. It doesn't create the tables at all.
Any ideas?

Related

I am trying to use database first approach in Entity Framework .NET using Oracle database

i am using visual studio 2019 and have created an C# console application, added "Oracle.EntityFrameworkCore" and "Microsoft.EntityFrameworkCore.Tools" packages. Oracle database is already available in Server Explorer. Now i want create Models from the existing Oracle database tables using Scaffold-DbContext.
NOTE: I AM BOUND TO USE OLD 2.2.6 VERSION OF "Microsoft.EntityFrameworkCore.Tools" OTHERWISE IT GENERATES ERROR AS:
1. Package restore failed. Rolling back package changes.
2. Version conflict detected for Microsoft.EntityFrameworkCore.Relational.
Need to execute this sort of command:
Scaffold-DbContext "User Id=*****;Password=*****;Data Source=<*****>;" Oracle.EntityFrameworkCore -OutputDir Models

VS2012 and Entity Framework 6.1.3 compatibility

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

Migration in rails 5 with jruby

I create a database via rake task successfully. But I have a problem while migrating my migration files for models. I always get the following problem related to postgres.

EF 4.3.1 Migration - how to downgrade a production database?

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”

EF (Entity Framework) 4.3 Migration tool does not work on EF 4.1 DB

I want to modify one DB which was developed with EF 4.1 (Code First). I upgraded the project into EF 4.3 and follow this steps:
http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-automatic-migrations-walkthrough.aspx
Everything is going well, but when I want to test on current DB (EF 4.1 Code First), Update-Database raise this error:
Cannot scaffold the next migration because the target database was
created with a version of Code First earlier than EF 4.3 and does not
contain the migrations history table. To start using migrations
against this database, ensure the current model is compatible with the
target database and execute the migrations Update process. (In Visual
Studio you can use the Update-Database command from Package Manager
Console to execute the migrations Update process).
I was wondering how I can migrate an EF 4.1 (Code First) DB? Moreover that DB is live and has data and I cannot drop tables.
You need to create an empty migration and execute it prior to doing changes to your model. It will create the migration history table for you. After that you can use migrations for new changes. I wrote walkthrough article about this topic.
Run "Add-Migration InitialMigration -IgnoreChanges" before doing any changes to the model.. Make the required changes, then run "update-database"