Database Migration is getting failed due to NLOG.config in Visual Studio 2022 Mac - entity-framework

I started programming with Visual Studio 2022 in Mac M1. I am developing an application with .net core 6 and initially I used to develop in Windows. I copied my project and started to work in VS 2022 Mac. While doing the DB Migration (Using dotnet CLI) I am getting error and it's getting failed due to NLog.config. I am using NLog for the logging functionality.
DataAccess layer and WepAPI are separate project in a solution.DBContextClass and migration scripts are present in DataAccess Layer and the connection string is present in WebAPI.
Error while doing the db migration:
Time Elapsed 00:00:01.65 Build succeeded. dotnet exec --depsfile
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplicationWebAPI.deps.json
--additionalprobingpath /Users/MASKED/.nuget/packages --runtimeconfig /Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplicationWebAPI.runtimeconfig.json
/Users/MASKED/.dotnet/tools/.store/dotnet-ef/6.0.7/dotnet-ef/6.0.7/tools/net6.0/any/tools/netcoreapp2.0/any/ef.dll
database update -c ApplicationDbContext --assembly
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplication.DataAccess.dll
--project /Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess/MyCoreApplication.DataAccess.csproj
--startup-assembly /Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0/MyCoreApplicationWebAPI.dll
--startup-project /Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/MyCoreApplicationWebAPI.csproj
--project-dir /Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess/
--root-namespace MyCoreApplication.DataAccess --language C# --framework net6.0 --nullable --working-dir /Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess
--verbose Using assembly 'MyCoreApplication.DataAccess'. Using startup assembly 'MyCoreApplicationWebAPI'. Using application base
'/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/bin/Debug/net6.0'.
Using working directory
'/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI'.
Using root namespace 'MyCoreApplication.DataAccess'. Using project
directory
'/Users/MASKED/Projects/MyCoreApplication/MyCoreApplication.DataAccess/'.
Remaining arguments: . Finding DbContext classes... Finding
IDesignTimeDbContextFactory implementations... Finding application
service provider in assembly 'MyCoreApplicationWebAPI'... Finding
Microsoft.Extensions.Hosting service provider... Using environment
'Development'. NLog.NLogConfigurationException: Exception when loading
configuration
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/nlog.config
---> System.Xml.XmlException: Root element is missing. at System.Xml.XmlTextReaderImpl.Throw(Exception e) at
System.Xml.XmlTextReaderImpl.ParseDocumentContent() at
System.Xml.XmlTextReaderImpl.Read() at
System.Xml.XmlReader.MoveToContent() at
NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader,
String fileName, Boolean ignoreErrors) --- End of inner exception
stack trace --- at
NLog.Config.XmlLoggingConfiguration.Initialize(XmlReader reader,
String fileName, Boolean ignoreErrors) at
NLog.Config.XmlLoggingConfiguration..ctor(XmlReader reader, String
fileName, LogFactory logFactory) at
NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfiguration(XmlReader
xmlReader, String configFile, LogFactory logFactory) at
NLog.Config.LoggingConfigurationFileLoader.LoadXmlLoggingConfigurationFile(LogFactory
logFactory, String configFile) at
NLog.Config.LoggingConfigurationFileLoader.TryLoadLoggingConfiguration(LogFactory
logFactory, String configFile, LoggingConfiguration& config) at
NLog.Config.LoggingConfigurationFileLoader.Load(LogFactory logFactory,
String filename) at
NLog.Config.LoggingConfigurationWatchableFileLoader.Load(LogFactory
logFactory, String filename) at
NLog.LogFactory.LoadConfiguration(String configFile, Boolean optional)
at NLog.LogFactory.LoadConfiguration(String configFile) at
NLog.LogManager.LoadConfiguration(String configFile) at
Program.$(String[] args) in
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/Program.cs:line
25
--- End of stack trace from previous location --- at Microsoft.Extensions.Hosting.HostFactoryResolver.HostingListener.CreateHost()
at
Microsoft.Extensions.Hosting.HostFactoryResolver.<>c__DisplayClass10_0.b__0(String[]
args) at
Microsoft.Extensions.Hosting.HostFactoryResolver.<>c__DisplayClass13_0.b__3(String[]
args) at
Microsoft.EntityFrameworkCore.Design.Internal.AppServiceProviderFactory.CreateFromHosting(String[]
args)
An error occurred while accessing the Microsoft.Extensions.Hosting services. Continuing without the application service provider. Error:
Exception when loading configuration
/Users/MASKED/Projects/MyCoreApplication/MyCoreApplicationWebAPI/nlog.config
No application service provider was found. Finding DbContext classes
in the project... Found DbContext 'ApplicationDbContext'.
Microsoft.EntityFrameworkCore.Design.OperationException: Unable to
create an object of type 'ApplicationDbContext'. For the different
patterns supported at design time, see
https://go.microsoft.com/fwlink/?linkid=851728 --->
System.InvalidOperationException: Unable to resolve service for type
'Microsoft.EntityFrameworkCore.DbContextOptions1[MyCoreApplication.DataAccess.Data.ApplicationDbContext]' while attempting to activate 'MyCoreApplication.DataAccess.Data.ApplicationDbContext'. at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type) at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13() --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13() at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func1
factory) at
Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String
contextType) at
Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.UpdateDatabase(String
targetMigration, String connectionString, String contextType) at
Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabaseImpl(String
targetMigration, String connectionString, String contextType) at
Microsoft.EntityFrameworkCore.Design.OperationExecutor.UpdateDatabase.<>c__DisplayClass0_0.<.ctor>b__0()
at
Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action
action)
Unable to create an object of type 'ApplicationDbContext'. For the different patterns supported at design time, see
https://go.microsoft.com/fwlink/?linkid=851728

Related

EF Core Power Tools EntityFrameworkCore.Design.OperationException suddenly occurring on "Add DbContext Diagram"

I've been using EF Core Power Tools to assist with learning EF Core. The data project is simply a class library that contains the base DbContext used by the associated web app, plus the migrations folder.
It's been working fine until suddenly this error occurs when I "Add DbContext Diagram"
System.InvalidOperationException: Error:
Microsoft.EntityFrameworkCore.Design.OperationException: Unable to create an object of type 'EventFinderContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728
---> System.InvalidOperationException: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions`1[EventFinderData.EventFinderContext]' while attempting to activate 'EventFinderData.EventFinderContext'.
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters)
at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13()
--- End of inner exception stack trace ---
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13()
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func`1 factory)
at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)
at Modelling.EfCoreModelBuilder.BuildResult(String outputPath, String startupOutputPath, Boolean generateDdl) in C:\Code\EFCorePowerTools\src\GUI\efpt30.core\EFCoreModelBuilder.cs:line 41
at Modelling.Program.Main(String[] args) in C:\Code\EFCorePowerTools\src\GUI\efpt30.core\Program.cs:line 56
at async Task EFCorePowerTools.Handlers.ModelAnalyzerHandler.GenerateAsync(string outputPath, Project project, GenerationType generationType)
I'm not sure even where to start looking to investigate, so any pointers would be appreciated please. The solution builds okay, the database seems fine, and the associated Blazor project also runs fine.
Not sure if its helpful but in my data project, the constructor for the DbContext is this:
namespace EventFinderData
{
public class EventFinderContext : DbContext
{
public EventFinderContext(DbContextOptions<EventFinderContext> options) : base(options)
{
}
}
}
You have to register EventFinderContext in program.cs
builder.Services.AddDbContext<EventFinderContext>(
opt => opt.UseSqlServer("Your_connection_string"));
As advised by ErikEJ (the author of Power Tools) the diagram function only works on the executable project. Once I had added a web application project to my solution, the original console and data layer projects in that solution no longer worked for creating the diagram.

Entity Framework Generator For Postgres

I found a nice article in http://www.loresoft.com/Generate-ASP-NET-Web-API. I've read and test it with the SQL Server database with success. Now, I want to change the database engine into PostgreSQL, I've migrated the database from SQL Server into PostgreSQL.
But, When I am executing:
efg generate -c ""Host=localhost;Username=admin;Database=dbTest;Password=admin;Persist Security Info=True""
The console showing me:
17:18:04 W Option file not found: generation.yml
17:18:04 I Using default options
17:18:04 D Creating database model factory for: SqlServer
17:18:04 I Loading database model ...
17:18:04 F Host terminated unexpectedly
System.ArgumentException: Keyword not supported: 'host'.
at Microsoft.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms, Boolean firstKey)
at Microsoft.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms)
at Microsoft.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
at Microsoft.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
at Microsoft.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
at Microsoft.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
at Microsoft.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
at Microsoft.Data.SqlClient.SqlConnection..ctor(String connectionString)
at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, DatabaseModelFactoryOptions options)
at EntityFrameworkCore.Generator.CodeGenerator.GetDatabaseModel(IDatabaseModelFactory factory) in C:\projects\entityframeworkcore-generator\src\EntityFrameworkCore.Generator.Core\CodeGenerator.cs:line 371
at EntityFrameworkCore.Generator.CodeGenerator.Generate(GeneratorOptions options) in C:\projects\entityframeworkcore-generator\src\EntityFrameworkCore.Generator.Core\CodeGenerator.cs:line 40
at EntityFrameworkCore.Generator.GenerateCommand.OnExecute(CommandLineApplication application) in C:\projects\entityframeworkcore-generator\src\EntityFrameworkCore.Generator\GenerateCommand.cs:line 76
--- End of stack trace from previous location where exception was thrown ---
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.Invoke(MethodInfo method, Object instance, Object[] arguments)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.OnExecute(ConventionContext context, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.Conventions.ExecuteMethodConvention.<>c__DisplayClass0_0.<<Apply>b__0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken)
at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
at EntityFrameworkCore.Generator.Program.Main(String[] args) in C:\projects\entityframeworkcore-generator\src\EntityFrameworkCore.Generator\Program.cs:line 50
I think I was missing some dependencies package. But, I am not sure what is it.
Thank you very much
I've found the solution, and decide to post it here because It may help other people in the future.
Actually, efg command will use SqlServer provider if we not mentioning any "provider" parameter. So, I've revised my command into:
efg generate -c "Host=localhost;Username=admin;Database=dbTest;Password=admin;Persist Security Info=True" -p PostgreSQL

Google.Apis.Http.ConfigurableMessageHandler exception at runtime

I have problem with Google Analytics API .NET.
While connecting to GA via api at line
var certificate = new X509Certificate2(pathToPrivateKey, passToPrivateKey, X509KeyStorageFlags.Exportable);
ServiceAccountCredential credential = new ServiceAccountCredential(new ServiceAccountCredential.Initializer(serviceAccountEmailAddress)
{
Scopes = scopes
}.FromCertificate(certificate));
It give below error
Message=The type initializer for 'Google.Apis.Http.ConfigurableMessageHandler' threw an exception.
Source=Google.Apis.Core
TypeName=Google.Apis.Http.ConfigurableMessageHandler
StackTrace:
at Google.Apis.Http.ConfigurableMessageHandler..ctor(HttpMessageHandler httpMessageHandler)
at Google.Apis.Http.HttpClientFactory.CreateHttpClient(CreateHttpClientArgs args) in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Core\Apis\Http\HttpClientFactory.cs:line 37
at Google.Apis.Auth.OAuth2.ServiceAccountCredential..ctor(Initializer initializer) in c:\code\google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Auth.DotNet4\OAuth2\ServiceAccountCredential.cs:line 217
at ConsoleApplication3.Program.AuthenticationGA(String pathToPrivateKey, String serviceAccountEmailAddress, String passToPrivateKey) in C:\Documents and Settings\pivotaladmin.WA-PIV\my documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\Program.cs:line 30
at ConsoleApplication3.Program.Main(String[] args) in C:\Documents and Settings\pivotaladmin.WA-PIV\my documents\visual studio 2010\Projects\ConsoleApplication3\ConsoleApplication3\Program.cs:line 69
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.FileLoadException
Message=Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
Source=Google.Apis.Core
FileName=System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes
FusionLog==== Pre-bind state information ===
Project type: Console app
.NET Framework 4.0
MS Visual Studio 2010 Express
Windows Server 2003
I tried the same code on Windows 7 and it works.
I have no idea what goes wrong.
Any idea?
It looks like your main problem is the inner exception you got:
InnerException: System.IO.FileLoadException
Message=Could not load file or assembly 'System, Version=2.0.5.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e, Retargetable=Yes' or one of its dependencies.
The good news is that you should just install the following patch: KB2468871, as suggested here:
Could not load file or assembly System, Version=2.0.5.0 in .NET 4 MVC 4 application

Entity Framework 5 IBM DB2 EntityException The underlying provider failed on ConnectionString

I am using Visual Studio 2012 to build a web application. The application uses webforms, Entity Framework 5 with an IBM DB2 database server. I have the latest IBM Drivers v10.1.2 installed on both my development machine and my web server. The web server is running Windows Server 2008 R2 Standard x64bit OS.
Problem Im having is running the app under Visual Studio's IIS Express on my local machine works fine, however when I deployed the app the web server I am getting problems EF and DB2 Drivers. Here is the error and stack trace. What am doing wrong?!
Server Error in '/' Application.
--------------------------------------------------------------------------------
ERROR [] [IBM][CLI Driver] SQL0000W Statement processing was successful.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: IBM.Data.DB2.DB2Exception: ERROR [] [IBM][CLI Driver] SQL0000W Statement processing was successful.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[DB2Exception (0x80004005): ERROR [] [IBM][CLI Driver] SQL0000W Statement processing was successful.]
IBM.Data.DB2.ConnSettingsFromXmlConfig.ProcessFromXmlConfig(DB2Connection connection, String dbname, String host, String port, String tmpClientEncAlg, String tmpAuthentication, String prevdb, String prevdb_ori, DB2ConnSettings& sSettings, DB2ConnSettingsInternal& sSettingsInternal, StringBuilder& modifiedValue) +21370
IBM.Data.DB2.DB2ConnPool.ReplaceConnectionStringParms(DB2Connection connection, String szValue, DB2ConnSettings& pSettings, DB2ConnSettingsInternal& pSettingsInternal, Boolean bAttach, Boolean pushDownStrAppended) +19113
IBM.Data.DB2.DB2Connection.set_ConnectionString(String value) +187
System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +325
[EntityException: The underlying provider failed on ConnectionString.]
System.Data.EntityClient.EntityConnection.ChangeConnectionString(String newConnectionString) +391
System.Data.EntityClient.EntityConnection..ctor(String connectionString) +43
System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection) +78
System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name, AppConfig config) +32
System.Data.Entity.Internal.LazyInternalConnection.Initialize() +127
System.Data.Entity.Internal.LazyInternalConnection.CreateObjectContextFromConnectionModel() +13
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +281
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +52
System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() +15
System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() +37
System.Linq.Queryable.Where(IQueryable`1 source, Expression`1 predicate) +63
....
I had the same problem and changing the app pool to Network Service did the trick.

How to fix “The ConnectionString property has not been initialized” in nopCommerce

I'm trying to integrate nopCommerce into a third party system but am hitting a problem when I try to access any nopCommerce pages. Because I'm integrating with a third party system I've had to merge web.configs and copy all files over. I have a standalone install of nopCommerce aswell and that is running fine.
Any help would be greatly appreciated.
The error I am getting is as follows:
The ConnectionString property has not been initialized.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: The ConnectionString property has not been initialized.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[InvalidOperationException: The ConnectionString property has not been initialized.]
System.Data.SqlClient.SqlConnection.PermissionDemand() +5038498
System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) +20
System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +126
System.Data.SqlClient.SqlConnection.Open() +125
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +52
[EntityException: The underlying provider failed on Open.]
System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure) +161
System.Data.EntityClient.EntityConnection.Open() +98
System.Data.Objects.ObjectContext.EnsureConnection() +81
System.Data.Objects.ObjectQuery1.GetResults(Nullable1 forMergeOption) +46
System.Data.Objects.ObjectQuery1.System.Collections.Generic.IEnumerable<T>.GetEnumerator() +44
System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func2 keySelector, Func2 elementSelector, IEqualityComparer1 comparer) +151
System.Linq.Enumerable.ToDictionary(IEnumerable1 source, Func`2 keySelector) +90
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetAllSettings() +542
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingByName(String name) +121
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingValue(String name) +49
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingValueBoolean(String name, Boolean defaultValue) +54
NopSolutions.NopCommerce.BusinessLogic.Configuration.Settings.SettingManager.GetSettingValueBoolean(String name) +41
NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.CustomerManager.get_UsernamesEnabled() +45
NopSolutions.NopCommerce.Web.Administration.LoginPage.ApplyLocalization() +108
NopSolutions.NopCommerce.Web.Administration.LoginPage.Page_Load(Object sender, EventArgs e) +40
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +91
NopSolutions.NopCommerce.Web.BaseNopAdministrationPage.OnLoad(EventArgs e) +44
System.Web.UI.Control.LoadRecursive() +74
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2207
You need to have a valid connection string.
After you pass the database installation phase (when you fill in the database settings) nop commerce is keeping the database information in a file that is not within the project, you can find it within the App_Data folder in the Presentation\Nop.Web\App_Data\ named Settings.txt, update it if you need and run the application again.
You need to have a valid connection string for the NopCommerce database in web.config, and you need to ensure that it gets read.
At Application_Start in global.asax NopCommerce reads in the connection string and injects it into the business logic DLL. If that doesn't happen, the data access layer (in the business logic DLL) won't be able to open a connection and you'll get the error you just posted. I suggest check web.config and global.asax; if both look good put a breakpoint in Application_Start.
The connection string is not held in the web.config file in nopcommerce... it is in the ConnectionStrings.config file. You might want to check for that file and copy it over if it is not there or put your connection string in there if the file is there and the string is not.