How to debug Code First Migration - entity-framework-migrations

I am using the Code First Migration in my project.
In the first migration file we are executing the .sql files, these are executing perfectly.
But when I execute the new .sql file in the latest migration file those are not execute and there is no error in the package manager console.
Is there a way to debug the migration file step by step?
Thanks

Related

How do I access sql script which is inside the package on Octopus Server?

I need to specify the path to the file with migrations script in Execute Sql Script step. This step run on Octopus Server, and file is inside the package.
I have a dotnet ef migrations script -i ... as a build step.
Produced sql file is copied to the directory where application is published to.
This directory is then pushed to Octopus package feed.
Documentation shows how to access package contents in pre- or post-deploy scripts, but that is probably not what I need because applying migrations is a separate step in deployment process.
You could read the contents of the script into an output variable in a pre/post deployment script in the deployment step and then use that variable value as the script body in the SQL - Execute Script step.
Since this is a community step there is no way currently to specify that the script source is from a package.

How to create the deployproj file from the command line

the deployproj is a temporary file that is generated from the dproj file every time we deploy the project from the delphi ide. But it's not the case from the command line. I build and deploy my project like this :
MSBuild %ProjectDir%\MyApp.dproj /p:Config=Release /p:Platform=Android /t:Build;Deploy
but if the deployproj not exist (or is not updated), then this command will failed :( Is their any way to generate the deployproj from the command line ?

Flyway Ant tries to open .sql file as a zip, fails with ZipException

I am trying to use Flyway in my Ant project to run DDL scripts. I managed to configure the classpath so that Flyway sees the migration scripts. When I run the flyway:migrate task, I get this exception:
Unable to obtain resource from (...)/src/ddl/V1__create_tables_logging.sql: java.util.zip.ZipException: error in opening zip file
[flyway:migrate] Unable to obtain resource from (...)/src/ddl/V1__create_tables_logging.sql:
[flyway:migrate] java.util.zip.ZipException: error in opening zip file
There is a suggestion at the end:
[flyway:migrate] Possible solution: run the Ant javac and copy tasks first so Flyway can find the migrations
But my project is not a Java application, I have no java sources to be compiled with javac. Does Flyway need to have the migration scripts packed in a jar? Can't it simply run some text files with SQL statements?
Unfortunately, you didn't provide a configuration you have, without it it's hard to tell, what exactly causes this issue.
But it seems odd to me, that you are not using location property of the task, but classpath. Try to specify the directory with you migration scripts as follows:
<flyway:migrate>
<locations>
<location path="path/to/migrations"/>
</locations>
...
</flyway:migrate>

Netbeans build.xml to execute when using Ant

I'm relatively new to using build files and Ant to compile and execute from a command line so i wanted to know how it would be possible to modify the build-impl.xml file auto generated from netbeans so that after it compiles it also executes the program.
Currently when i type just "ant" in the command window where the build.xml file is listed it compiles and etc but then says
-do-jar-copylibs:
[copylibs] Nothing to copy.
[echo] To run this application from the command line without Ant, try:
[echo] java -jar "C:\Users\Eric\Documents\Word Documents\Java Test Code\NetbeansVersion\Cops\dist\Cops.jar"
I can run that command and it will run fine, but i want the program to execute by just typing ant.
The build.xml file - Pastebin
Build-impl.xml file - Pastebin
There are a couple "tasks" available in ant that you could use to accomplish this.
You can use either of these:
Java Task,
Exec Task
Those documentation pages provide examples as well. Before you go there though, you might want to start at the basic manual to get an idea of the structure of an ant build file to determine where and how you want to add this execution step in.
It feels a little "off" to me to have your build script executing the program, but I'm sure you've got a reason, so I might suggest adding a new target that does the build steps and then also runs this command to kick off the program. That way you've still got the option of running the build without running the program.

second time model changes in codefirst

I initially generated configuration and Initialcreate classes successfully by mapping the model.
Now I changed the model (by adding one more property) and tried to execute below commands in project manager console.
The commands I have tried:
PM> add-migration
cmdlet Add-Migration at command pipeline position 1
Supply values for the following parameters:
Name: Configuration
Scaffolding migration 'Configuration'.
The Designer Code for this migration file includes a snapshot of your current Code First model. This snapshot is used to calculate the changes to your model when you scaffold the next migration. If you make additional changes to your model that you want to include in this migration, then you can re-scaffold it by running `Add-Migration Configuration` again.
PM> update-database -verbose
Using StartUp project 'Demo'.
The project 'Demo' failed to build.
PM>
When I tried to execute add-migration command then it generated a partial class with same name as Configuration.cs. Now I found two Configuration files but inheritance is different between both classes. What should I do or what am I doing in wrong manner?
After that I executed the commands again with different name and it worked but when I executed the command Update-database then received an error which I mentioned below:
Table registeration already exists
Use
add-migration YourMigrationName -force

Resources