/// <summary> /// Configures the <see cref="DbContext" /> to use MySQL Sever. /// </summary> /// <param name="optionsBuilder">DbContext option builder.</param> /// <param name="connection">MySQL connection object.</param> /// <param name="MySQLOptionsAction">DbContext option builder action.</param> /// <returns>DbContext option builder using MySQL.</returns> public static DbContextOptionsBuilder UseMySQL(this DbContextOptionsBuilder optionsBuilder, DbConnection connection, Action <MySQLDbContextOptionsBuilder> MySQLOptionsAction = null) { var extension = GetOrCreateExtension(optionsBuilder); extension = (MySQLOptionsExtension)extension.WithConnection(connection); IDbContextOptionsBuilderInfrastructure o = optionsBuilder as IDbContextOptionsBuilderInfrastructure; o.AddOrUpdateExtension(extension); MySQLOptionsAction?.Invoke(new MySQLDbContextOptionsBuilder(optionsBuilder)); return(optionsBuilder); }
/// <summary> /// Configures the context to connect to a MySQL database. /// </summary> /// <param name="optionsBuilder"> The builder being used to configure the context. </param> /// <param name="connection"> /// An existing <see cref="DbConnection" /> to be used to connect to the database. If the connection is /// in the open state then EF will not open or close the connection. If the connection is in the closed /// state then EF will open and close the connection as needed. /// </param> /// <param name="mysqlOptionsAction">An optional action to allow additional MySQL specific configuration.</param> /// <returns> The options builder so that further configuration can be chained. </returns> public static DbContextOptionsBuilder UseMySQL( this DbContextOptionsBuilder optionsBuilder, DbConnection connection, Action <MySQLDbContextOptionsBuilder> mysqlOptionsAction = null) { var extension = GetOrCreateExtension(optionsBuilder); extension.Connection = connection; IDbContextOptionsBuilderInfrastructure o = optionsBuilder as IDbContextOptionsBuilderInfrastructure; o.AddOrUpdateExtension(extension); ConfigureWarnings(optionsBuilder); mysqlOptionsAction?.Invoke(new MySQLDbContextOptionsBuilder(optionsBuilder)); return(optionsBuilder); }
public static DbContextOptionsBuilder UseMySQL(this DbContextOptionsBuilder optionsBuilder, string connectionString, Action <MySQLDbContextOptionsBuilder> MySQLOptionsAction = null) { var extension = optionsBuilder.Options.FindExtension <MySQLOptionsExtension>(); if (extension == null) { extension = new MySQLOptionsExtension(); } extension.ConnectionString = connectionString; IDbContextOptionsBuilderInfrastructure o = optionsBuilder as IDbContextOptionsBuilderInfrastructure; o.AddOrUpdateExtension(extension); MySQLOptionsAction?.Invoke(new MySQLDbContextOptionsBuilder(optionsBuilder)); return(optionsBuilder); }
/// <summary> /// Configures the <see cref="DbContext" /> to use MySQL Sever. /// </summary> /// <param name="optionsBuilder">DbContext option builder.</param> /// <param name="connectionString">MySQL connection string.</param> /// <param name="MySQLOptionsAction">DbContext option builder action.</param> /// <returns>DbContext option builder using MySQL.</returns> public static DbContextOptionsBuilder UseMySQL( [NotNull] this DbContextOptionsBuilder optionsBuilder, [NotNull] string connectionString, [CanBeNull] Action <MySQLDbContextOptionsBuilder> MySQLOptionsAction = null) { var extension = optionsBuilder.Options.FindExtension <MySQLOptionsExtension>(); if (extension == null) { extension = new MySQLOptionsExtension(); } extension = (MySQLOptionsExtension)extension.WithConnectionString(connectionString); IDbContextOptionsBuilderInfrastructure o = optionsBuilder as IDbContextOptionsBuilderInfrastructure; o.AddOrUpdateExtension(extension); MySQLOptionsAction?.Invoke(new MySQLDbContextOptionsBuilder(optionsBuilder)); return(optionsBuilder); }