我正在评估3.9目前和租户创建不起作用。
它在执行此代码时失败:
CheckErrors(await _roleManager.CreateStaticRoles(tenant.Id));这是我得到的例外:
Mvc.ExceptionHandling.AbpExceptionFilter - Format of the initialization string does not conform to specification starting at index 0.
System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
at System.Data.Common.DbConnectionOptions.GetKeyValuePair(String connectionString, Int32 currentPosition, StringBuilder buffer, Boolean useOdbcRules, String& keyname, String& keyvalue)
at System.Data.Common.DbConnectionOptions.ParseInternal(Dictionary`2 parsetable, String connectionString, Boolean buildChain, Dictionary`2 synonyms, Boolean firstKey)
at System.Data.Common.DbConnectionOptions..ctor(String connectionString, Dictionary`2 synonyms)
at System.Data.SqlClient.SqlConnectionString..ctor(String connectionString)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnectionOptions(String connectionString, DbConnectionOptions previous)
at System.Data.ProviderBase.DbConnectionFactory.GetConnectionPoolGroup(DbConnectionPoolKey key, DbConnectionPoolGroupOptions poolOptions, DbConnectionOptions& userConnectionOptions)
at System.Data.SqlClient.SqlConnection.ConnectionString_Set(DbConnectionPoolKey key)
at System.Data.SqlClient.SqlConnection.set_ConnectionString(String value)
at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerConnection.CreateDbConnection()相同的实体框架连接可以与我添加的其他ApplicationService类一起工作。不知道为什么只有在创建租户时才会失败。我正在扩展样本模板,它可以在ASP.NET样板站点上免费获得。
非常感谢你的帮助。你好,扎伊努
发布于 2019-03-11 13:59:20
直到代码部署在Azure中,我才意识到它最终会出现异常"System.ApplicationException:未能找到内容根文件夹“。
对我来说幸运的是,在这里有一个相同的讨论,https://github.com/aspnetboilerplate/aspnetboilerplate-templates/issues/43和修复是一样的。
var startupPath = System.IO.Directory.GetCurrentDirectory();var配置= AppConfigurations.Get(startupPath);tenant.ConnectionString =System.IO.Directory.GetCurrentDirectory
发布于 2019-03-10 08:53:42
在Create方法下的TenantAppService类中,注释掉了从输入DTO创建加密连接字符串的代码。添加了一种从配置中读取连接字符串的方法,这在我的情况下是可行的,因为我只有一个数据库,所有的tenants.This数据库都很小,它只存储有关租户的元数据,而大多数应用程序数据将存储在Azure存储中。
public override async Task<TenantDto> Create(CreateTenantDto input)
{
CheckCreatePermission();
// Create tenant
var tenant = ObjectMapper.Map<Tenant>(input);
//this code is commented since we have single database for all tenants
//tenant.ConnectionString = input.ConnectionString.IsNullOrEmpty()
// ? null
// : SimpleStringCipher.Instance.Encrypt(input.ConnectionString);
//This would read connection string from configuration and pass it to
//connectionstring property of AbpTenant
var configuration =
AppConfigurations.Get(WebContentDirectoryFinder.CalculateContentRootFolder());
tenant.ConnectionString = SimpleStringCipher.Instance.Encrypt(configuration.GetConnectionString(OneCloudConsts.ConnectionStringName));https://stackoverflow.com/questions/55077049
复制相似问题