-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Migrations after field rename with Datetime type doesn't work #9344
Comments
Confirmed. Something is wrong. I get the following on the latest 2.0.0 bits. migrationBuilder.DropColumn(
name: "DateTime",
table: "Entities");
migrationBuilder.AddColumn<DateTime>(
name: "Updated",
table: "Entities",
type: "datetime2",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)); For some reason, the Migrations model differ isn't pairing up the old an new column. |
Hmm, I'm getting this for all types, not just |
Looks like the model snapshot returns @ajcvickers @AndriySvyryd Should we change the way |
If we want to make it consistent, we could either:
|
var oldType = new MyContextModelSnapshot().Model
.FindEntityType("MyProject.MyEntity")
.FindProperty("MyProperty")
.Relational().ColumnType;
var newType = new MyContext().Model
.FindEntityType("MyProject.MyEntity")
.FindProperty("MyProperty")
.Relational().ColumnType;
Assert.Equal(oldType, newType); |
@bricelam Probably need a design meeting, as we've already discussed this at least twice |
Will cue it up. Although this is mostly orthogonal to #8624. |
I'm leaning towards writing it into the model snapshot and compensating for older snapshots. |
Agree with @bricelam. |
I changed my approach (see the PR). There were a few other places we only want the value if it was explicitly configured by the user. Also, while writing them in the snapshot is fine, that would make it more difficult to keep them out of the migrations where they definitely shouldn't be. |
@bricelam Example: my GUID columns are being generated with this: migrationBuilder.AddColumn<Guid>(... type: "BLOB" ... );
migrationBuilder.CreateTable(name: "X", columns: table => new {
Id = table.Column<Guid>(type: "BLOB", nullable: false)
} ... Since i generate migrations with a mode=memory sqlite database, and my application runs on postgres (that dont understand BLOB), its breaking now. Your pull request already fixes this issue, right? |
Yes, that is another symptom of the same underlying bug that was fixed. |
This patch bug is approved for the 2.0.x patch. Please send a PR to the |
@bricelam - Are we sure, that the cause of issue in first post is the same? I am not able to repro empty migration. |
I wasn't able to repro it either, but I did find the bug that we ended up fixing while trying. |
Hi, we have a public test feed that you can use to try out the ASP.NET/EF Core 2.0.3 patch! To try out the pre-release patch, please refer to the following guide:
We are looking for feedback on this patch. We'd like to know if you have any issues with this patch by updating your apps and libraries to the latest packages and seeing if it fixes the issues you've had, or if it introduces any new issues. If you have any issues or questions, please reply on this issue to let us know as soon as possible. Thanks, |
I just renamed field in many tables with type DateTime
Then I add a migration but the Up() method is empty
but it works well with string fields
Steps to reproduce
Include a complete code listing (or project/solution) that we can run to reproduce the issue.
Rename a field Datetime
Add a migration
Partial code listings, or multiple fragments of code, will slow down our response or cause us to push the issue back to you to provide code to reproduce the issue.
In command shell:
dotnet ef migrations add "data_5" -c Db -v -p ..\GrrDev2.Data\GrrDev2.Data.csproj
Migration class:
Further technical details
EF Core version: (found in project.json or packages.config)
Microsoft.EntityFrameworkCore (2.0.0)
Database Provider:
Microsoft.EntityFrameworkCore.SqlServer (2.0.0)
Operating system:
The text was updated successfully, but these errors were encountered: