EF Core modifying table from modelBuilder code in OnModelCreating()

c# ef-core-2.2 ef-migrations entity-framework entity-framework-core

Question

I have the below code in the context file and it's implemented in the dev db, so I just need to create this in the production db. But I'm not sure how with EF Core and a ASP.Net Core Vue.js application?

I don't have any migration files in the project, so I don't think the previous dev was using migrations, is there another way to make these changes to the production db without using code first migrations and having it create a migration folder in the project?

Coming from a ASP.Net MVC EF code first background I understand the add-migration and update-database calls to update a db with Entity Framework. But this is a Vue.js with ASP.Net Core project from work I've inherited and it doesn't have this migration folder so I'm curious to know how the prev developer made the changes on the db side? Unless he did it in the db directly!?

If he had used add-migrations and update-database I would see the migration folder and files in the project, but I don't.

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Witness>()
            .Property(p => p.WitnessName)
            .HasComputedColumnSql("(rtrim(concat([LastName],', ',[FirstName],' ',[MiddleName])))");
 } 
1
0
4/25/2019 3:57:08 PM

Popular Answer

[Without migrations] I'm curious to know how the prev developer made the changes on the db side? Unless he did it in the db directly!?

If not manually, then perhaps a database initializer. You can always create an empty database with a database initializer. You can then use that empty database to generate a schema diff to apply to your production database.

0
4/25/2019 7:24:24 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow