I am having problems with a BLAZOR SERVER + Entity Framework 6.4 application
The entity framework part is in a separate dll project (framework 4.6.2) shared by other projects. DB microsoft SqlServer (Express 2016)
The blazor part is an asp.net core 5.0 project and razor server pages
EVERYTHING WORKS ON THE DEVELOPMENT WORKSTATION
installed on windows 2019 / IIS 10, environment configured as Development, Staging and Production (with related app.json configuration files) the DB access part does NOT work
Everything is blocked at the initialization phase of the context expressed as a class derived from the EF6 DbCOntext in which I explicitly pass the entire connection string
in particular, everything in here freezes
Snippet
public MainDbContext(string connectionString) : base(connectionString)
{
Log.Info($"init MainDbContext {connectionString}");
try
{
Database.CreateIfNotExists();
Log.Error("CreateIfNotExists - DONE");
Database.Initialize(false);
}
catch (Exception exc)
{
Log.Error($"Eccezione in fase init MainDbContext{Environment.NewLine}{exc}");
}
Log.Error("init MainDbContext - DONE");
}
when it tries to execute one of the two calls Database.CreateIfNotExists () or DatabaseInitialize () (I tried to comment 1 at a time) it stops and TRIES to access the DB NOT with user / pwd indicated (SQL authentication) but with the generic user from domain \ machinename:
conf string (changed name / actual pwd) "Data Source = SERVER_NAME; Initial Catalog = SHERPA.BBM; User ID = sa; Password = SA_PASSWORD; integrated security = True; MultipleActiveResultSets = True; App = EntityFramework"
here is example registered / logged error
2021-05-12 16:17:09.5875 | INFO | SHERPA.BBM.Controllers.BBMController | Richiesta avvio classe BBMController, connString: Data Source=SERVER_NAME;Initial Catalog= SHERPA.BBM ;User ID=sa;Password=SA_PASSWORD;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework;
2021-05-12 16:17:10.2111 | INFO | SHERPA.BBM.MainDbContext | init MainDbContext Data Source=SQL2012DEV;Initial Catalog=SHERPA.BBM;User ID=sa;Password=keyhammer16;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework;
2021-05-12 16:17:12.8557 | ERROR | SHERPA.BBM.MainDbContext | Eccezione in fase init MainDbContext
System.Data.SqlClient.SqlException (0x80131904): Login failed for user 'steamw\W2019-IIS-DEV$'.
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.<>c.<Open>b__13_0(DbConnection t, DbConnectionInterceptionContext c)
at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
at System.Data.Entity.SqlServer.SqlProviderServices.<>c__DisplayClass60_0.<UsingConnection>b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass2_0.<Execute>b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection)
at System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase()
at System.Data.Entity.Migrations.Utilities.DatabaseCreator.Create(DbConnection connection)
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()
at System.Data.Entity.Internal.DatabaseCreator.CreateDatabase(InternalContext internalContext, Func`3 createMigrator, ObjectContext objectContext)
at System.Data.Entity.Internal.InternalContext.CreateDatabase(ObjectContext objectContext, DatabaseExistenceState existenceState)
at System.Data.Entity.Database.Create(DatabaseExistenceState existenceState)
at System.Data.Entity.CreateDatabaseIfNotExists`1.InitializeDatabase(TContext context)
at System.Data.Entity.Internal.InternalContext.<>c__DisplayClass66_0`1.<CreateInitializationAction>b__0()
at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action)
at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization()
at System.Data.Entity.Internal.LazyInternalContext.<>c.<InitializeDatabase>b__58_0(InternalContext c)
at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action)
at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase()
at System.Data.Entity.Internal.InternalContext.Initialize()
at System.Data.Entity.Database.Initialize(Boolean force)
at SHERPA.BBM.MainDbContext..ctor(String connectionString) in C:\Users\samuele\source\repos\SHERPA\SHERPA.BBM\MainDbContext.cs:line 54
ClientConnectionId:df9bbde7-c148-4153-b99d-d2faab4b7fb9
Error Number:18456,State:1,Class:14
2021-05-12 16:17:12.9256 | ERROR | SHERPA.BBM.MainDbContext | init MainDbContext - DONE
any help would be greatly appreciated !
Fortunately i resolved !
Ensure that Integrated Security is set to False in the connection string.
User contributions licensed under CC BY-SA 3.0