Skip to content
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

EF Core 1.1 Separate Assembly Migrations Not Considered #9601

Closed
HelloKitty opened this issue Aug 28, 2017 · 5 comments
Closed

EF Core 1.1 Separate Assembly Migrations Not Considered #9601

HelloKitty opened this issue Aug 28, 2017 · 5 comments

Comments

@HelloKitty
Copy link

Describe what is not working as expected.

Add-Migration appears to not consider generated migrations in a separate project/assembly reference when generating a new migrations for a separate context that references that table through a foreign key. It will create the scaffolding, if that is what is it still called, for the foreign table. This causes Update-Database to fail since the table will already exist.

If you are seeing an exception, include the full exceptions details (message and stack trace).

Exception message: Table 'avatarentries' already exists
Stack trace:

   at MySql.Data.MySqlClient.MySqlDataReader.ActivateResultSet(ResultSet resultSet)
   at MySql.Data.MySqlClient.MySqlDataReader.<ReadFirstResultSetAsync>d__62.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.MySqlDataReader.<CreateAsync>d__61.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.CommandExecutors.TextCommandExecutor.<ExecuteReaderAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.CommandExecutors.TextCommandExecutor.<ExecuteNonQueryAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery()
   at Microsoft.EntityFrameworkCore.Storage.Internal.MySqlRelationalCommand.<ExecuteAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.EntityFrameworkCore.Storage.Internal.MySqlRelationalCommand.Execute(IRelationalConnection connection, String executeMethod, IReadOnlyDictionary`2 parameterValues, Boolean closeConnection)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.MigrationCommandExecutor.ExecuteNonQuery(IEnumerable`1 migrationCommands, IRelationalConnection connection)
   at Microsoft.EntityFrameworkCore.Migrations.Internal.Migrator.Migrate(String targetMigration)
   at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String targetMigration, String contextType)
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_1.<.ctor>b__0()
   at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)```

Steps to reproduce

Include a complete code listing (or project/solution) that we can run to reproduce the issue.

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.

Repro too bulky

Further technical details

EF Core version: (found in project.csproj or packages.config) 1.1
Database Provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer)
Operating system:
IDE: (e.g. Visual Studio 2015)

@HelloKitty HelloKitty changed the title EF Core 1.1 EF Core 1.1 Seperate Assembly Migrations Not Considered Aug 28, 2017
@HelloKitty HelloKitty changed the title EF Core 1.1 Seperate Assembly Migrations Not Considered EF Core 1.1 Separate Assembly Migrations Not Considered Aug 28, 2017
@HelloKitty
Copy link
Author

You can manually remove the create table and drop table from the migrations to temporarily fix this. But it would nice if it could be discoverable or hinted to the tools that the table exists by pointing it to other migrations in a separate assembly.

@ajcvickers
Copy link
Member

@HelloKitty I think from reading this that you are looking for the functionality described in issue #2725. If this is not the case, can you explain a bit more what you are asking?

@HelloKitty
Copy link
Author

HelloKitty commented Aug 29, 2017

@ajcvickers That appears to be functionality that would address the issue. Some sort of hinting to the location of migrations to consider or explicit exclusions for table generation would solve it, as described by the issue you linked.

I apologize for the duplicate!

@HelloKitty
Copy link
Author

Closing due to duplicate of #2725

@divega
Copy link
Contributor

divega commented Aug 29, 2017

@HelloKitty no need to apologize!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants