Jump to content

Modifying WRobot Config


Smarter

Recommended Posts

I am using Entity Framework in my project which requires additions to the app.config: 
 

						  <configSections>
							<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
							<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
						  </configSections>
						  <entityFramework>
							<providers>
							  <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
							  <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6, Version=6.10.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>
							</providers>
							<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
							  <parameters>
								<parameter value="mssqllocaldb" />
							  </parameters>
							</defaultConnectionFactory>
						  </entityFramework>

However, if I modify WRobot.exe.config the application will not start. 

image.thumb.png.a73ba529e75ca3339e3261bace039c25.png

Link to comment
Share on other sites

I figured it out, I programatically registered the types

 

 public class WoWClassDbConfig : DbConfiguration
    {public WoWClassDbConfig()
        {
            // Register Entity Framework provider
            SetProviderServices("MySql.Data.MySqlClient", new MySqlProviderServices());
            SetDefaultConnectionFactory(new MySqlConnectionFactory());

        }

        public void SetupConnection(string username, string password, string server)
        {
            var entityConnectionStringBuilder = new EntityConnectionStringBuilder
            {
                Provider = "MySql.Data.MySqlClient",
                ProviderConnectionString =
                    $"server={server};user id={username};password={password};persistsecurityinfo=True;database=wowdb;ConvertZeroDateTime=true;SslMode=none",
                Metadata = "WoWClassicDb.csdl|WoWClassicDb.ssdl|WoWClassicDb.msl"
            };
            entityConnectionStringBuilder.ProviderConnectionString += ";pooling=false";

            ConnectionString = entityConnectionStringBuilder.ToString();
        }

        public string ConnectionString { get; set; }
    }

    [DbConfigurationType(typeof(WoWClassDbConfig))]
    public partial class WoWClassicDb : DbContext
    {
        public WoWClassicDb(string connectionString)
            : base(connectionString)
        {

        }

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...