-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DbMigrator - Problems with existing migrations #62
Comments
Hello @forsti83 , I believe disabling the option public BloggingContext() : base((My.ConnectionString))
{
this.Configuration.BatchMigration.IsEnabled = false;
} Let me know if that fixed it. Best Regards, Jon |
Hello @JonathanMagnan , that fixed it. Thank you very much! Has EF Classic another default value for this config setting than EF? Best Regards, |
Hello Andreas, I'm not sure to understand you question. If you ask if there is another config that could affect the migration, I believe that's the only one |
Hello Jon, no, the question is, if you have a clue, why our migrations are working with EF 6.4.4 (without setting the BatchMigration config option to false), but are failing with EF Classic 7.1.34 (again without setting the BatchMigration config option to false)? Thank you and best regards, |
Oh, It fail in EF Classic since by default, we batch command. Which means, instead of executing for example 100 SQL command to create all your tables and index, perhaps only 1-2 commands are executed. So when batching the migration, this part will be executed way faster. However, a custom script like your make SQL fail unless it's in a execute method. This is similar to creating first a table: CREATE TABLE A
(
ColumnInt INT
) then executing the following SQL ALTER TABLE dbo.A
ADD ColumnInt2 INT
UPDATE A
SET ColumnInt2 = 1 even if somewhat valid, you will get the same error. However, you found a workaround to make it works with the When directly in SSMS, you can also use the "GO" workaround: ALTER TABLE dbo.A
ADD ColumnInt2 INT
GO
UPDATE A
SET ColumnInt2 = 1
GO Let me know if that explains correctly the current behavior. |
Hi Jon, thank you very much for the detailed information! Best regards, |
Hi!
We have migrated our application from EF 6.4.4 to EF Classic 7.1.34. We are using MS SQL Server as database. Usually the application user executes the pending migrations at application start. Internally the DbMigrator class is used for this in code:
Since the migration to EF Classic we are facing problems with migrations of this type:
We are getting the exception that the column "ColumnName" is invalid at runtime, when the SQL-statement is executed. We can fix this problem with wrapping the SQL statement in an EXEC:
It seems that the DbMigrator is not finishing the batch after the AddColumn statement like EF 6.4.4 did. Is there any explanation for this or even a config option for getting the old behaviour?
The text was updated successfully, but these errors were encountered: