DalSoft / dalsoft-website-comments

0 stars 0 forks source link

blog/index.php/2016/12/13/entity-framework-core-seeding-using-migrations/ #24

Open utterances-bot opened 5 days ago

utterances-bot commented 5 days ago

Blog | DalSoft Ltd

We're an established, highly capable development consultancy specialising in full stack development and DevOps.

https://www.dalsoft.co.uk/blog/index.php/2016/12/13/entity-framework-core-seeding-using-migrations/

DalSoft commented 5 days ago

Lecgacy Comments

Steven McVicar says: January 7, 2017 at 2:01 pm Hi, thanks for this post! It’s very useful. Our team are currenlty debating whether to use EF Core or EF 6. EF Core is our preferred choice. However there are a number of issues with the latest release which are making us nervous. Your solutions above will help us a great deal.

I’m curious to know though… Can you get migrations to run using dotnet CLI commands from within Visual Studio Team Services? If so can you let me know how you achieved this please?

Cheers Steve


DalSoft says: May 15, 2017 at 10:36 am @steven I do exactly this myself use:

dotnet ef –project ../DalSoft.Data –startup-project ../DalSoft.Data database update –environment production

Replace with your project name.


Alfredo says: January 4, 2018 at 6:54 pm I want to seed different data in each environment. I don’t believe your solution can achieve this.


DalSoft says: February 13, 2018 at 1:51 pm Hi Alfredo, this is exactly what it does! Just change the –environment switch to your environment.

The –environment switch isn’t available after EF Core 2.0, but it has just changed to use the ASPNETCORE_ENVIRONMENT environment setting instead.

So, in your seed code just check the value of the ASPNETCORE_ENVIRONMENT environment setting, and do the seed you want to do for that environment.


Pranita Shaha says: October 18, 2018 at 6:24 am This article contains very useful information on Entity Framework Core Seeding Using Migrations. Thanks for sharing this article.


bernyLed says: February 6, 2022 at 2:17 pm EF Core uses this table to track all the applied migrations. So, this means that if we create another migration in our code and apply it, EF Core will apply only the newly created migration. But how does EF Core know what migration needs to be applied?