Rollend Xavier
Rollend Xavier

Reputation: 600

Can we run DDL scripts using FromSql in EF Core

I know this is not what intended for, but just want to know FromSql whether we can use like this

_dbContext.Student.FromSql("ALTER TABLE Student ADD Grade varchar(max)")

I just want to push this once to my Azure SQL Test environment (still I am in development phase and dont have direct access to SQL editor), better i could have run Migrations, but some point i had messed with it, have to rely on something else. This is like a temporary fix.

Upvotes: 1

Views: 456

Answers (1)

bricelam
bricelam

Reputation: 30415

_dbContext.Database.ExecuteSql("ALTER TABLE Student ADD Grade varchar(max)")

Upvotes: 1

Related Questions