Я использую ядро Entity Framework .Net 2.2 и Microsoft SqlServer 2017 и пытаюсь обновить модели, сгенерированные генератором кода Entity Framework (первый подход к базе данных). Я был в состоянии изначально создать все свои сущности и сопоставления. Я внес изменения в базу данных и произвел восстановление, используя файл .bkp, чтобы обновить копию на моем экземпляре локального сервера sql.
После обновления я использую следующую команду cli в консоли диспетчера пакетов:
efg generate -c "Сервер = localhost \ SQLEXPRESS; База данных = SOLA_DEV; Trusted_Connection = True;"
но я получаю следующую ошибку. Кто-нибудь знает, что я делаю неправильно или с чего начать расследование? Это говорит мне о сбое экземпляра, но я подключаюсь к нему нормально. Я пытался убедиться, что схема была обновлена в sqlserver, все мои обновления видны после резервного копирования. Я пытался создать новое решение и создать его из той же базы данных, но у меня та же ошибка.
12:48:21 I Loading options file: generation.yml
12:48:21 I Loading database model ...
12:48:21 F Host terminated unexpectedly
System.InvalidOperationException: Instance failure.
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, Boolean applyTransientFaultHandling, String accessToken)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
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.SqlClient.SqlConnection.Open()
at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(DbConnection connection, IEnumerable`1 tables, IEnumerable`1 schemas)
at Microsoft.EntityFrameworkCore.SqlServer.Scaffolding.Internal.SqlServerDatabaseModelFactory.Create(String connectionString, IEnumerable`1 tables, IEnumerable`1 schemas)
at EntityFrameworkCore.Generator.CodeGenerator.GetDatabaseModel(IDatabaseModelFactory factory) in C:\projects\entityframeworkcore-generator\src\EntityFrameworkCore.Generator.Core\CodeGenerator.cs:line 248
at EntityFrameworkCore.Generator.CodeGenerator.Generate(GeneratorOptions options) in C:\projects\entityframeworkcore-generator\src\EntityFrameworkCore.Generator.Core\CodeGenerator.cs:line 41
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)
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.<>c__DisplayClass142_0.<OnExecute>b__0()
at EntityFrameworkCore.Generator.Program.Main(String[] args) in C:\projects\entityframeworkcore-generator\src\EntityFrameworkCore.Generator\Program.cs:line 50
Файл generation.yml не изменился с момента его создания.
namespace: '{Database.Name}'
directory: .\
database:
connectionName: ConnectionStrings:Generator
userSecretsId: //Removed for example
data:
context:
name: '{Database.Name}Context'
baseClass: DbContext
namespace: '{Project.Namespace}.Data'
directory: '{Project.Directory}\Data'
entity:
namespace: '{Project.Namespace}.Data.Entities'
directory: '{Project.Directory}\Data\Entities'
mapping:
namespace: '{Project.Namespace}.Data.Mapping'
directory: '{Project.Directory}\Data\Mapping'
query:
generate: true
indexPrefix: By
uniquePrefix: GetBy
namespace: '{Project.Namespace}.Data.Queries'
directory: '{Project.Directory}\Data\Queries'
model:
shared:
namespace: '{Project.Namespace}.Domain.Models'
directory: '{Project.Directory}\Domain\Models'
read:
generate: true
name: '{Entity.Name}ReadModel'
create:
generate: true
name: '{Entity.Name}CreateModel'
update:
generate: true
name: '{Entity.Name}UpdateModel'
mapper:
generate: true
name: '{Entity.Name}Profile'
baseClass: AutoMapper.Profile
namespace: '{Project.Namespace}.Domain.Mapping'
directory: '{Project.Directory}\Domain\Mapping'
validator:
generate: true
name: '{Model.Name}Validator'
baseClass: AbstractValidator<{Model.Name}>
namespace: '{Project.Namespace}.Domain.Validation'
directory: '{Project.Directory}\Domain\Validation'