Quantcast
Channel: Entity Framework
Viewing all articles
Browse latest Browse all 10318

Created Unassigned: Update-Database with ConnectionString to remote server fails running Seed method with 'serverName' cannot be null [1387]

$
0
0
Using EntityFramework 6 beta 1, when running "update-database" in the package manager console to update a local database, everything succeeds. When running the following command, there is an error:

update-database -ConnectionString "Server=ourserver.eu-west-1.compute.amazonaws.com;Database=OurDatabase;Uid=username;Pwd=password;" -ConnectionProviderName "System.Data.SqlClient"

The error:
System.ArgumentException: The argument 'serverName' cannot be null, empty or contain only white space.
at System.Data.Entity.Utilities.Check.NotEmpty(String value, String parameterName)
at System.Data.Entity.Infrastructure.ExecutionStrategyKey..ctor(String providerInvariantName, String serverName)
at System.Data.Entity.Core.Common.DbProviderServices.GetExecutionStrategy(DbConnection connection, DbProviderFactory providerFactory)
at System.Data.Entity.Core.Common.DbProviderServices.GetExecutionStrategy(DbConnection connection, MetadataWorkspace metadataWorkspace)
at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.<GetElementFunction>b__2[TResult](IEnumerable`1 sequence)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)
at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)
at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)
at System.Linq.Queryable.SingleOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
at System.Data.Entity.Migrations.DbSetMigrationsExtensions.AddOrUpdate[TEntity](DbSet`1 set, IEnumerable`1 identifyingProperties, TEntity[] entities)
at System.Data.Entity.Migrations.DbSetMigrationsExtensions.AddOrUpdate[TEntity](IDbSet`1 set, TEntity[] entities)
at LaZook.Core.Migrations.Seeding.SeedImpl.AddOrUpdateLanguage(ILaZookContext context, Guid id, String languageCode, String languageString) in c:\Users\Joshua\Dropbox\LaZookRepository\src\LaZook.Core\Migrations\Seeding\SeedImpl.cs:line 72
at LaZook.Core.Migrations.Seeding.SeedImpl.PopulateLanguages(ILaZookContext context) in c:\Users\Joshua\Dropbox\LaZookRepository\src\LaZook.Core\Migrations\Seeding\SeedImpl.cs:line 77
at LaZook.Core.Migrations.Seeding.SeedImpl.PopulateCountriesLanguagesAndCurrencies(ILaZookContext context) in c:\Users\Joshua\Dropbox\LaZookRepository\src\LaZook.Core\Migrations\Seeding\SeedImpl.cs:line 101
at LaZook.Core.Migrations.Seeding.SeedImpl.Seed(ILaZookContext context) in c:\Users\Joshua\Dropbox\LaZookRepository\src\LaZook.Core\Migrations\Seeding\SeedImpl.cs:line 18
at LaZook.Core.Migrations.Configuration.Seed(LaZookContext context) in c:\Users\Joshua\Dropbox\LaZookRepository\src\LaZook.Core\Migrations\Configuration.cs:line 29
at System.Data.Entity.Migrations.DbMigrationsConfiguration`1.OnSeed(DbContext context)
at System.Data.Entity.Migrations.DbMigrator.SeedDatabase()
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.SeedDatabase()
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable`1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass9.<Update>b__8()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)

The database connection configuration for the local database, which is succeeding, is:

<connectionStrings><add name="LaZookContext" connectionString="Server=.;Database=LaZook;Integrated Security=SSPI;" providerName="System.Data.SqlClient" />

... where "LaZookContext" is the name of the DbContext derived class.

Other things to note, in case they are important:
- LaZookContext derives from a class which itself derives from DbContext
- LaZookContext has properties of type IDbSet<entity> rather than DbSet<entity>


Viewing all articles
Browse latest Browse all 10318

Trending Articles