1

.net core 3.0 I developed my application with a sql lite database. Now I am trying to migrate my database to MySQL but I am getting this error when I run my code. After running, it fails and does not create the new Database.

my connection string

"ConnectionStrings": { "DefaultConnection": "Server=localhost; Database=datingapp; Uid=appuser; Pwd=4^.-:aX;vqU-QebT" },


ERROR


    fail: DatingApp.API.Program[0]
          An error occured during migration
    System.ArgumentException: Format of the initialization string does not conform to specification starting at index 63.
       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, Boolean useOdbcRules)
       at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
       at MySql.Data.MySqlClient.MySqlConnectionStringBuilder..ctor(String connectionString) in C:\projects\mysqlconnector\src\MySqlConnector\MySql.Data.MySqlClient\MySqlConnectionStringBuilder.cs:line 19
       at Microsoft.EntityFrameworkCore.MySqlDbContextOptionsExtensions.UseMySql(DbContextOptionsBuilder optionsBuilder, String connectionString, Action`1 mySqlOptionsAction)
       at DatingApp.API.Startup.<ConfigureProductionServices>b__5_0(DbContextOptionsBuilder x) in /Users/josephlyons/DatingApp/DatingApp.API/Startup.cs:line 47
       at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass1_0`2.<AddDbContext>b__0(IServiceProvider p, DbContextOptionsBuilder b)
       at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.DbContextOptionsFactory[TContext](IServiceProvider applicationServiceProvider, Action`2 optionsAction)
       at Microsoft.Extensions.DependencyInjection.EntityFrameworkServiceCollectionExtensions.<>c__DisplayClass10_0`1.<AddCoreServices>b__0(IServiceProvider p)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitFactory(FactoryCallSite factoryCallSite, RuntimeResolverContext context)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSiteMain(ServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitCache(ServiceCallSite callSite, RuntimeResolverContext context, ServiceProviderEngineScope serviceProviderEngine, RuntimeResolverLock lockType)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScopeCache(ServiceCallSite singletonCallSite, RuntimeResolverContext context)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2.VisitCallSite(ServiceCallSite callSite, TArgument argument)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.DynamicServiceProviderEngine.<>c__DisplayClass1_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngine.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
       at Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.GetService(Type serviceType)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
       at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
       at DatingApp.API.Program.Main(String[] args) in /Users/.../DatingApp/DatingApp.API/Program.cs:line 25
    info: Microsoft.Hosting.Lifetime[0]
          Now listening on: http://localhost:5000
    info: Microsoft.Hosting.Lifetime[0]
          Application started. Press Ctrl+C to shut down.
    info: Microsoft.Hosting.Lifetime[0]
          Hosting environment: Production
    info: Microsoft.Hosting.Lifetime[0]
          Content root path: /Users/.../DatingApp/DatingApp.API

3
  • Hi ly6n, for ease of reading, try wrapping your connection string in backticks ` to make it look like code. Also, is that all the relevant code? Perhaps provide us with a little more context (not too much code, just a bit more). Finally, I would guess the error is this right here: System.ArgumentException: Format of the initialization string does not conform to specification starting at index 63. Your 63rd character is either the space or the colon, so I would guess that is part of the issue Commented Oct 31, 2019 at 15:13
  • Is database always been a MySQL database? Did you rename the database? What changes did you make since database last worked? Commented Oct 31, 2019 at 15:15
  • Come from dotnet and angular course of Mr. Neil, I stuck on migration db and moving to production. Finally fixed by just changing connection string. Uid and pwd doesn't work in my case, so I change to User and Password and it works. You might need to checking the here: mysqlconnector.net/connection-options Commented May 30, 2020 at 10:12

2 Answers 2

3

Your password contains semi colon in that case instead of this

Pwd=4^.-:aX;vqU-QebT"

Try this and let me know whether this help you or no.

Pwd='4^.-:aX;vqU-QebT'"
Sign up to request clarification or add additional context in comments.

Comments

0

It is meant to be user and password rather than uid and pwd.

Refer to this page MySQL EF corehttps://dev.mysql.com/doc/connector-net/en/connector-net-entityframework-core.html

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.