.net - How to execute the script through cmd or powershell generated by EF Migrations -


earlier, using ef automaticmigrations in project. still in development environment only. now, going production environment , want use code-based migrations. have generated initialcreate.cs migration file using add-migration
then, made changes model , added new migration file

add-migration addnewpropertytotable1 

i created script migration file using

update-database -script 

and saved in .sql file. tried execute sql file through msdn documentation, gave me error of:

cannot find object "dbo.tablename" because not exist or not have permission.

i using cmd in administrative mode , database server configured user admin , have necessary permissions. when went through script, there nothing mentioned database name. following:

alter table [dbo].[tablename] add [property] [int] not null default 0 insert [dbo].[__migrationhistory]([migrationid], [contextkey], [model], [productversion]) values (n'201708180946444_addnewpropertytotable1', n'schoollibrary.migrations.configuration',  0x1f8b08000a1e617494253858d7168e92c64b6216e22d756d519626ab025afad44be16c298e4b212160c375706975e72f0 , n'6.1.3-40302') 

can please tell me following:
1. following correct steps ?
2. think, have pass connection string .sql file. if, yes have manually write in somewhere or how automatically include using ef migrations?
3. have modify .sql file like

use databasename; go ///// 
  1. what best way run script on client machine ?

thanks in advance


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -