You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately I have no clue what EF is trying to tell me with the exception. This is what I did:
Upgraded my EF7-beta4 project to beta6
Added a simple string property to an entity
Created a migration via dnx . ef migration add
Manually cleaned up the migrations Up and Down methods, because the automatic scaffolding tried to (re-)create all tables etc.
Tried to apply the new migration via dnx . ef migration apply
The exception I get:
dnx . ef migration apply
Using context 'Db'.
Using database 'Wuzlstats' on server '(localdb)\MSSQLLocalDB'.
System.InvalidOperationException: The navigation property 'LeagueId' cannot be added to entity type 'Wuzlstats.Models.Ga
me' because the entity type is defined in shadow state and navigations properties cannot be added to shadow state.
at Microsoft.Data.Entity.Metadata.EntityType.AddNavigation(String name, ForeignKey foreignKey, Boolean pointsToPrinci
pal)
at Microsoft.Data.Entity.Metadata.Internal.InternalEntityTypeBuilder.Navigation(String navigationName, ForeignKey for
eignKey, Boolean pointsToPrincipal, ConfigurationSource configurationSource, Boolean canOverrideSameSource)
at Microsoft.Data.Entity.Metadata.Internal.InternalEntityTypeBuilder.Navigation(String navigationName, ForeignKey for
eignKey, Boolean pointsToPrincipal, ConfigurationSource configurationSource)
at Microsoft.Data.Entity.Metadata.Internal.InternalEntityTypeBuilder.Relationship(InternalEntityTypeBuilder principal
EntityTypeBuilder, InternalEntityTypeBuilder dependentEntityTypeBuilder, String navigationToPrincipalName, String naviga
tionToDependentName, IReadOnlyList`1 foreignKeyProperties, IReadOnlyList`1 principalProperties, ConfigurationSource conf
igurationSource, Nullable`1 isUnique, Nullable`1 isRequired, Func`2 onRelationshipAdding)
at Microsoft.Data.Entity.Metadata.Internal.InternalEntityTypeBuilder.Relationship(InternalEntityTypeBuilder principal
EntityTypeBuilder, InternalEntityTypeBuilder dependentEntityTypeBuilder, String navigationToPrincipalName, String naviga
tionToDependentName, ConfigurationSource configurationSource, Nullable`1 isUnique, Boolean strictPrincipal)
at Microsoft.Data.Entity.Metadata.Internal.InternalEntityTypeBuilder.Relationship(EntityType principalEntityType, Ent
ityType dependentEntityType, String navigationToPrincipalName, String navigationToDependentName, ConfigurationSource con
figurationSource, Nullable`1 isUnique, Boolean strictPrincipal)
at Microsoft.Data.Entity.Metadata.Builders.EntityTypeBuilder.ReferenceBuilder(EntityType relatedEntityType, String na
vigationName)
at Microsoft.Data.Entity.Metadata.Builders.EntityTypeBuilder.Reference(String relatedTypeName, String navigationName)
at Wuzlstats.Migrations.Initial.<>c.<BuildTargetModel>b__6_4(EntityTypeBuilder b) in C:\Users\saxx\Documents\Wuzlst
ats\src\Wuzlstats\Migrations\20150519184700_Initial.Designer.cs:line 85
at Microsoft.Data.Entity.ModelBuilder.Entity(String name, Action`1 buildAction)
at Wuzlstats.Migrations.Initial.BuildTargetModel(ModelBuilder builder) in C:\Users\saxx\Documents\Wuzlstats\src\Wuz
lstats\Migrations\20150519184700_Initial.Designer.cs:line 83
at Microsoft.Data.Entity.Migrations.Infrastructure.MigrationModelFactory.Create(Action`1 onModelCreating)
at Microsoft.Data.Entity.Migrations.Migrator.ApplyMigration(Migration migration)
at Microsoft.Data.Entity.Migrations.Migrator.ApplyMigrations(String targetMigration)
at Microsoft.Data.Entity.Commands.MigrationTool.ApplyMigration(String migrationName, String contextTypeName, String s
tartupAssemblyName)
at Microsoft.Data.Entity.Commands.Program.<>c__DisplayClass13_0.<ApplyMigration>b__0()
at Microsoft.Data.Entity.Commands.Program.Execute(String startupProject, Func`1 invoke)
at Microsoft.Data.Entity.Commands.Program.ApplyMigration(String migration, String context, String startupProject)
at Microsoft.Data.Entity.Commands.Program.<>c__DisplayClass10_3.<Main>b__9()
at Microsoft.Framework.Runtime.Common.CommandLine.CommandLineApplication.Execute(String[] args)
at Microsoft.Data.Entity.Commands.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider s
erviceProvider)
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider s
erviceProvider)
at dnx.host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args, FrameworkName targetFramework)
at dnx.host.RuntimeBootstrapper.Execute(String[] args, FrameworkName targetFramework)
Everything works fine when I create a new database from the model, only trying to migrate an existing database fails.
Migrations don't upgrade very well between pre-releases. There's been a lot of code churn in that area recently. Try deleting all your migrations, the model snapshot, and your database, then add a new migration and apply.
Thanks! Not really happy with that, because I need to drop my existing database and create a new one (and move all existing data to the new one), but I guess that comes with using a preview :)
Creating a new database works fine, by the way.
Unfortunately I have no clue what EF is trying to tell me with the exception. This is what I did:
string
property to an entitydnx . ef migration add
Up
andDown
methods, because the automatic scaffolding tried to (re-)create all tables etc.dnx . ef migration apply
The exception I get:
Everything works fine when I create a new database from the model, only trying to migrate an existing database fails.
The affected code is on https://github.com/saxx/Wuzlstats/, please see this branch for the exact changes I did: https://github.com/saxx/Wuzlstats/compare/master...Timeouts?expand=1
What is a "shadow state", what is this exception trying to tell me, and how can I fix it? Thanks!
The text was updated successfully, but these errors were encountered: