Bug #82433 Fail updating database when changing relationship in EF Code First
Submitted: 3 Aug 2016 18:03 Modified: 7 Apr 2017 10:37
Reporter: Julian GR Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.9.8.0 OS:Windows
Assigned to: CPU Architecture:Any
Tags: Code First, entity framework, migrations

[3 Aug 2016 18:03] Julian GR
Description:
If i change a one to many relationship (In fluent API) from Optional to Required , the process of updating the database fails.
The error message is : Additional information: Table 'table' doesn't exist

How to repeat:

1) Create a visual studio project with Entity Framework and MySQL Connector 6.9.8.0
2) Enable Migrations with the AutomaticMigrationsEnabled = true and AutomaticMigrationDataLossAllowed = true
1) Create the following Entities:
    
    public class Entity1 
    {
        public int Entity1Id { get; set; }
        public string Name { get; set; }
        public List<Entity2> Entities { get; set; }
    }

    public class Entity2 
    {
        public int Entity2Id { get; set; }
        public string Name { get; set; }
        public Entity1 Entity1 { get; set; }
        public int? Entity1Id { get; set; }
    }

2) Add the following Configuration to Entity2 

    public class Entity1Configuration : EntityTypeConfiguration<Entity1>
    {
        public Entity1Configuration()
        {
            HasMany(e1 => e1.Entities).WithOptional(e => e.Entity1);
        }
    }

3) Update databse from the console using update-database command

4) Change the entity configuration to:
    public class Entity1Configuration : EntityTypeConfiguration<Entity1>
    {
        public Entity1Configuration()
        {
            HasMany(e1 => e1.Entities).WithRequired(e => e.Entidad1);
        }
    }

5) Change the property Entity1Id from class Entity2 to non nullable

6) Update Database and fail
[4 Aug 2016 7:24] Chiranjeevi Battula
Hello Julian,

Thank you for the bug report.
I tried to reproduce the issue at my end using MySQL Connector/Net 6.9.9 but not seeing any issues in migrations.
Could you please provide repeatable test case (steps,full stack trace, sample code etc. - please make it as private if you prefer) to confirm this issue at our end?

Thanks,
Chiranjeevi.
[4 Aug 2016 13:56] Julian GR
Hello Chiranjeevi Battula, 
Thanks for your answer. I uploaded a file (via sftp) with a visual studio test project and a video showing how to reproduce the bug.
[11 Aug 2016 13:00] Julian GR
you could see it ?
[18 Aug 2016 9:49] Chiranjeevi Battula
Hello Julian,

Thank you for your feedback.
I could not find any file related to this bug. Could you please share us file details to confirm this issue at our end?
(If the data you need to attach is more than 3MB, you should create a compressed archive of the data and a README file that describes the data with a filename that includes the bug number (recommended filename: mysql-bug-data-82433.zip) and upload one to sftp.oracle.com).

Thanks,
Chiranjeevi.
[18 Aug 2016 12:37] Julian GR
i uploaded but the file via sftp following the instructions ( with the readme file and the correct name) but the file is retained only for 7 days and you took lot of time. 
I recently uploaded again
[16 Sep 2016 12:33] Chiranjeevi Battula
Hello Julian,

Thank you for your feedback.
Could you please provide repeatable test case (steps, sample code\screenshots, create table statements/database etc. - please make it as private if you prefer) to confirm this issue at our end?
If you upload file through sftp, it will expire in 7 days and this will get the problem to developers for checking later. 

Thanks,
Chiranjeevi.
[16 Sep 2016 14:08] Julian GR
are you kidding me ?  you are stupid! i take the work of creating a project with all the code, recording a video and uploading it 2 times and then you answer me that ?
Go to hell
[7 Apr 2017 10:37] Chiranjeevi Battula
Hello Julian,

Thank you for the feedback.
I could not repeat the issue at our end using with Visual Studio 2015, Connector/NET 6.9.9.
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.