Как я могу заставить Nuget Gallery поддерживать mysql? - PullRequest
0 голосов
/ 26 апреля 2019

Я клонирую Nuget Gallery , и она основана на сервере sql.

Поскольку галерея NuGet использует entityframework 6, я пытался перейти на mysql, выполнив следующие шаги:

1.Замените строки подключения файла web.config ниже

<add name="Gallery.SqlServer" connectionString="server=localhost;uid=root;password=123456;database=NuGetGallery" providerName="MySql.Data.MySqlClient"/>
<add name="Gallery.SupportRequestSqlServer" connectionString="server=localhost;userid=root;password=123456;database=SupportRequest" providerName="MySql.Data.MySqlClient"/>

2.Замените раздел структуры объекта следующим:

<entityFramework codeConfigurationType="NuGetGallery.EntitiesConfiguration, NuGetGallery.Core">
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework"/>
<providers>
  <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" />
  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer"/>
</providers>

3.Заменить [DbConfigurationType(typeof(EntitiesConfiguration))] на [DbConfigurationType(typeof(MySqlEFConfiguration))] для EntitiesContext и SupportRequestDbContext

4.Замените конструктор EntitiesConfiguration () на

    public EntitiesConfiguration()
    {
        // Configure Connection Resiliency / Retry Logic
        // See https://msdn.microsoft.com/en-us/data/dn456835.aspx and msdn.microsoft.com/en-us/data/dn307226
        SetExecutionStrategy(MySqlProviderInvariantName.ProviderName, () => new MySqlExecutionStrategy());
    }

Но не повезло!

Когда я выполняю Update-Database -ConfigurationTypeName MigrationsConfiguration -Verbose, возникает исключение, как показано ниже:

Использование стартап-проекта NuGetGallery. Использование проекта NuGet «NuGetGallery». Укажите флаг '-Verbose', чтобы просмотреть операторы SQL, применяемые к целевой базе данных. System.NullReferenceException: ception 未 对象 引用 设置 到 对象 的 实例。 在 MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken (соединение DbConnection) 在 System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken (соединение DbConnection) 在 System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked (поставщик услуг DbProviderServicesServices, соединение DbConnection) 在 System.Data.Entity.Infrastructure.DefaultManifestTokenResolver. <> C__DisplayClass1.b__0 (Tuple 3 k) 在 System.Collections.Concurrent.ConcurrentDictionary 2.GetOrAdd (клавиша TKey, Func 2 valueFactory) 在 System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) 在 System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) 在 System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) 在 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) 在 System.Data.Entity.Internal.RetryLazy 2.GetValue (ввод TInput)) 在 System.Data.Entity.Internal.LazyInternalContext.InitializeContext () 在 System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes () 在 System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext () 在 NuGetGallery.ObjectMaterializedInterceptingDbContext.get_ObjectContext () 位置 E: \ git \ HSY.NugetGallery \ src \ NuGetGallery.Core \ Entities \ Interception \ ObjectMaterializedInterceptingDbContext.cs: 号 号 35 在 NuGetGallery.ObjectMaterializedInterceptingDbContext..ctor (String connectionString) 位置 E: \ git \ HSY.NugetGallery \ src \ NuGetGallery.Core \ Entities \ Interception \ ObjectMaterializedInterceptingDbContext.cs: 行 号 19 在 NuGetGallery.EntitiesContext..ctor (String connectionString, Boolean readOnly) 位置 E: \ git \ HSY.NugetGallery \ src \ NuGetGallery.Core \ Entities \ EntitiesContext.cs: 号 号 42 在 NuGetGallery.EntitiesContext..ctor () 位置 E: \ git \ HSY.NugetGallery \ src \ NuGetGallery.Core \ Entities \ EntitiesContext.cs: 号 号 34

...