Quantcast
Channel: MySQL Forums - Connector/NET and C#, Mono, .Net
Viewing all 1447 articles
Browse latest View live

running multiple queries with one connection (3 replies)

$
0
0
I'm writing an application (Windows based using Visual C# 2012) that will be interacting with a MYSQL database.

I have implemented the Singleton pattern for the connection so that each instance of the application is only allowed one connection (At a time) to the database, to keep resource usage down.

My issue now is that when I'm trying to perform multiple "read" queries (using ExecuteQuery), I get an exception thrown saying that there is already a connection open for the command and that the connection needs to be closed first.

I've tried to "close" the Command object, and then setting it to null, then reassigning it and then performing the query, but I still get the same error.

Any ideas?

Connector 6.9.3 brakes applications with old Membership and Role Provider (no replies)

$
0
0
I´ve experienced this problem in two different machines, one with windows 2008 server (production enviroment) and the other with windows 7 (developer machine). We have several web applications that worked with previous versions of the .net connector (versions 6.7.4 and 6.8.3) and they use MySqlMembership and MySqlRole provider without any problems until I installed the new connector (version 6.9.3), then they have stopped working showing this error: Unable to initialize provider. Missing or incorrect schema.
The reason why I´ve installed this connector is because We have started a new project that uses Entity Framework 6 and Asp .Net Identity 2.0 for authentication, so these technologies required the new version of the connector and this new project works fine, but my other applications stopped working.
So is there a way to have both my already in production applications with membership and the new EF6 project?
Thanks in advance.

confusing exception with MySql.Web.Security.MySQLMembershipProvider (1 reply)

$
0
0
Targeting ASP.NET MVC 4, using connector/NET 6.9.3 on win7/64

I have a new local instance of MySql, as well as a remote instance.

I used the MySql Website Configure tool in VS2013 to configure web.config

I tested the connection string for "LocalMySqlServer" using both VS Server Explorer as well as MySql Workbench, and connects fine.

When I try to launch the app I get the following startup error:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: Could not load type 'MySql.Data.MySqlClient.MySqlConnection' from assembly 'MySql.Web.v20, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.

Source Error:


Line 49: <providers>
Line 50: <remove name="MySQLMembershipProvider" />
Line 51: <add name="MySQLMembershipProvider"

type="MySql.Web.Security.MySQLMembershipProvider, MySql.Web.v20, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" applicationName="X_NAV_DMSEC" description="MySqlSimpleMembership Application" connectionStringName="LocalMySqlServer" writeExceptionsToEventLog="False" autogenerateschema="True" enableExpireCallback="False" enablePasswordRetrieval="False" enablePasswordReset="True" requiresQuestionAndAnswer="True" requiresUniqueEmail="False" passwordFormat="Clear" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="7" minRequiredNonalphanumericCharacters="1" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
Line 52: </providers>
Line 53: </membership>

Source File: C:\x-nav-dm-repo.git\branches\Case-Added\NAV-X-DM\X-NAV-DMSEC\web.config Line: 51

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34237


MySql.Web.V20.dll is in the GAC and also locally copied to Bin folder.



The above error message, Could not load type 'MySql.Data.MySqlClient.MySqlConnection' from assembly 'MySql.Web.v20, Version=6.9.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'.

is a little confusing, because 'MySql.Data.MySqlClient.MySqlConnection is found in assembly "MySql.Data" not MySql.Web.v20. I've assumed this is because of a connection string issue, but no joy.

I've also tried setting my "DefaultConnection" to be identical to "LocalMySqlServer" value with no effect.

This test app was originally configured to use SQL and a local DB, and that worked. After conversion using the MySql Website configuration tool, this error has appeared.

The target named schema/db exists on the local MySql instance, but there are no tables defined such as User. (These are autogenerated using the SQL scheme, and I thought they'd be autogenerated using MySql. But no joy. I'm going to try creating the tables manually and see if that works, but there is no indication in the MySql logs of any failures like this. The error in the Event logs is identical to the error above. Something is trying to pull a a type from the wrong assembly and failing?

TransactionScope - error in Reader.Read() (no replies)

$
0
0
Connector version - 6.9.4 (I have tried with earlier version as well and the same exception was thrown)
Visual Studios 2008 , Windows XP SP3, MySQL Serve 5.6

I am getting error when I use TransactionScope. The code in TransactionScope works fine for the first time but when I try to perform the same operation on any other record while reading the it throws error.

The operation I am performing the copying records from 2 or more tables and copy as new records and want to make sure that while copying either records for all tables are insert or none (Commit or rollback).

Using the statement - using (TransactionScope scope = new TransactionScope())

Am I missing something ?? Are there any setting which needs to be done to use TransactionScope in MYSQL. The same code works fine after removing transactionscope.

System.NullReferenceException was unhandled
Message="Object reference not set to an instance of an object."
Source="MySql.Data"
StackTrace:
at MySql.Data.MySqlClient.NativeDriver.FetchDataRow(Int32 statementId, Int32 columns)
at MySql.Data.MySqlClient.Driver.FetchDataRow(Int32 statementId, Int32 columns)
at MySql.Data.MySqlClient.ResultSet.GetNextRow()
at MySql.Data.MySqlClient.ResultSet.NextRow(CommandBehavior behavior)
at MySql.Data.MySqlClient.MySqlDataReader.Read()

In MSVS, why must I include EntityFramework.SqlServer to get EF 6 support in MySql (no replies)

$
0
0
By default, when I install the EntityFramework, it automatically adds two references:

EntityFramework
EntityFramework.SqlServer

Then, if create a mysql EF 6 ADO.NET Entity Model, it works.

However, if I delete the SqlServer reference and re-add the entiy, it then limits me to EF 5.

Just looking for an explanation as to why this is so. It was frustrating to find this problem while trying to create a "pure" MySql based project.

Thanks, Chris

Connector/net for MYSQL WORKBENCH 6.1 CE (1 reply)

$
0
0
please help me to search for connector/net for MYSQL WORKBENCH 6.1 CE, or anyone can give me advice on how to connect MYSQL WORKBENCH 6.1 CE to crystal report, im using vb 2012 professional. please help me,

Two databases limit one connection to each (no replies)

$
0
0
I have two separate databases that my .Net application needs to connect to (it's a Windows application, not a web app). It needs to be able to connect to both at the same time, so I'm looking for a way to limit the connection to each database to just one connection per database (thus preventing the application from opening a second connection to either of the databases).

I've played with the Singleton pattern, but that doesn't seem to work as i want it due to the nature of it only allows one connection at a time, regardless of how many databases you have. This could work, but I feel it would be more efficient to have one connection per databases, but no duplicate connections to either database.

Suggestions??

Cant Uninstall MySQL Connector 6.7.4 on windows 7 (1 reply)

$
0
0
...
...
...
MSI (s) (D8:BC) [11:45:44:122]: Note: 1: 1725
MSI (s) (D8:BC) [11:45:44:122]: Product: MySQL Connector Net 6.7.4 -- Removal failed.

MSI (s) (D8:BC) [11:45:44:146]: Instalační služba systému Windows provedla odebrání produktu. Název produktu: MySQL Connector Net 6.7.4. Verze produktu: 6.7.4. Jazyk produktu: 1033. Výrobce: Oracle. Stav odebrání (úspěch nebo chyba): 1603.

MSI (s) (D8:BC) [11:45:44:173]: Deferring clean up of packages/files, if any exist
MSI (s) (D8:BC) [11:45:44:173]: MainEngineThread is returning 1603
MSI (s) (D8:E8) [11:45:44:175]: RESTART MANAGER: Session closed.
=== Logging stopped: 8.10.2014 11:45:44 ===
MSI (s) (D8:E8) [11:45:44:177]: User policy value 'DisableRollback' is 0
MSI (s) (D8:E8) [11:45:44:177]: Machine policy value 'DisableRollback' is 0
MSI (s) (D8:E8) [11:45:44:177]: Incrementing counter to disable shutdown. Counter after increment: 0
MSI (s) (D8:E8) [11:45:44:179]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (s) (D8:E8) [11:45:44:179]: Restoring environment variables
MSI (s) (D8:E8) [11:45:44:180]: Destroying RemoteAPI object.
MSI (s) (D8:58) [11:45:44:180]: Custom Action Manager thread ending.
MSI (c) (7C:F0) [11:45:44:209]: Decrementing counter to disable shutdown. If counter >= 0, shutdown will be denied. Counter after decrement: -1
MSI (c) (7C:F0) [11:45:44:209]: MainEngineThread is returning 1603
=== Verbose logging stopped: 8.10.2014 11:45:44 ===

MySQL Connector Net 6.9.4 -- Installation failed (1 reply)

$
0
0
=== Logging stopped: 8.10.2014 12:02:53 ===
MSI (c) (F4:A8) [12:02:53:141]: Note: 1: 1708
MSI (c) (F4:A8) [12:02:53:141]: Product: MySQL Connector Net 6.9.4 -- Installation failed.

MSI (c) (F4:A8) [12:02:53:179]: Windows Installer installed the product. Product Name: MySQL Connector Net 6.9.4. Product Version: 6.9.4. Product Language: 1033. Manufacturer: Oracle. Installation success or error status: 1603.

MSI (c) (F4:A8) [12:02:53:202]: Grabbed execution mutex.
MSI (c) (F4:A8) [12:02:53:202]: Cleaning up uninstalled install packages, if any exist
MSI (c) (F4:A8) [12:02:53:202]: MainEngineThread is returning 1603
=== Verbose logging stopped: 8.10.2014 12:02:53 ===

My Sql Entity Framework 6 error with VS2013 (no replies)

$
0
0
Hi

I am trying to user EF6 for MySql in my new project.

My version of MySql Community Server is 5.6.21.I installed the entire suite so i have MySql conector Net 6.9.4 and i have MySql for Visual studio 1.2.3

Create a console App. Added reference to MySql.Data and MySql.Data.Entity.EF6

Added the following to my app.config
<entityFramework>
<providers>
<provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6"/>
</providers>
</entityFramework>

However when i go to add the new Ado.net Entity Data model and choose code first from database i get the error

an Entity Framework database provider compatible with this version could not be found for your data connection. if you have already installed a have already installed a comptible provider, ensure you have rebuilt your project before performing this action. Otherwise, exit this wizard, install a compatible provider, and rebuid your project before performing this action.

I have tried everything i could find on the forums - mo luck.

Any clues/tips

Thanks

Regards
Sid

unable to connect VS 2013 ro MySQL database (1 reply)

$
0
0
Hi, I am developing a database management system in VS 2013. I need to connect to the database. I was able to do it before or should i say, the connection was working before. But for some reason i started getting the error "The system detected an invalid pointer address in attempting to use a pointer argument in a call" every time my project tries to connect to the database.

-MySQL workbench version is 6.2.2
-VS 2013 express
-MySQL connector 6.9.3
-MySQL server 5.1

I already tried re-installing the applications but to no avail.

connection unexectedly terminated (1 reply)

$
0
0
Hi Friends,
I am trying to mysql database on web using .net but receiving following error message.
"connection unexectedly terminated"
thank you.
regards,
asad

Connector/NET 6.9.4 not getting uninstalled (10 replies)

$
0
0
Hi All

I am badly in need to install MySQL again in my windows 7 laptop.

I deleted MySQL from control panel

Deleted the folders from hard disk

Now when i try to install freshly installer is opening like Connector is still present.

Kindly help in this.

Thanks and Regards
Jawahir junaith

ASP.NET Web Forms and MySql Entity Framework: “Nested transactions are not supported” (no replies)

$
0
0
I have an ASP.NET web forms application, using the .Net Connector for MySql Entity Framework.

I've made a web application using MySql in the past, and never ran into this issue.

I'm currently getting ~40000 page views a day, and each day about 10 errors of 'Nested transactions are not supported.'

I can't figure out why it happens at all, or why it happens only once in awhile.

In a Master page Preload event I get an integer ID for the user and save it to a public variable:

using (var entity = new Entities())
{
var user = entity.my_aspnet_users.Single(i => i.name == Context.User.Identity.Name);
UserID = user.id;
if (HttpContext.Current.Request.Url.AbsolutePath != "###" && HttpContext.Current.Request.Url.AbsolutePath != "###")
{
if (user.Player == null)
Response.Redirect("###", true);
else
PlayerID = user.Player.PlayerID;
}
}
And then on the page:

using (var entity = new Entities())
if (entity.Players.Count(i => ###) == 1)
{
var user = entity.my_aspnet_users.Single(i => i.id == Master.UserID);
if (user.Player == null)
{
user.Player = entity.Players.Single(i => ###);
entity.SaveChanges();
}
Response.Redirect("###", false);
}
The error gets thrown on SaveChanges(). I don't know why it only happens sometimes. I also sometimes get the same error when a user registers on the site or resets their password using the standard ASP.NET control and MySql membership provider.

Anyway, for one, I thought nested transactions were allowed in MySql? Is there a setting I need to set? My MySql instance is 5.6.17 and I believe using default parameters - set up in Amazon RDS.

I'm using the Connector/Net 6.9.3, which I believe is still the current one in Nuget.

Does 'User.Identity.Name' access the database? Do you have any idea on where I can look to solve this?

Here's the stack trace of some exceptions if helpful:

Exception on example code: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.Data.Entity.Core.EntityException: An error occurred while starting a transaction on the provider connection. See the inner exception for details. ---> System.InvalidOperationException: Nested transactions are not supported.

at MySql.Data.MySqlClient.ExceptionInterceptor.Throw(Exception exception)

at MySql.Data.MySqlClient.MySqlConnection.Throw(Exception ex)

at MySql.Data.MySqlClient.MySqlConnection.BeginTransaction(IsolationLevel iso)

at MySql.Data.MySqlClient.MySqlConnection.BeginDbTransaction(IsolationLevel isolationLevel)

at System.Data.Common.DbConnection.BeginTransaction(IsolationLevel isolationLevel)

at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.b__0(DbConnection t, BeginTransactionInterceptionContext c)

at System.Data.Entity.Infrastructure.Interception.InternalDispatcher1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func3 operation, TInterceptionContext interceptionContext, Action3 executing, Action3 executed)

at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.BeginTransaction(DbConnection connection, BeginTransactionInterceptionContext interceptionContext)

at System.Data.Entity.Core.EntityClient.EntityConnection.<>c__DisplayClassf.b__d()

at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)

at System.Data.Entity.Core.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel)

--- End of inner exception stack trace ---

at System.Data.Entity.Core.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel)

at System.Data.Entity.Core.EntityClient.EntityConnection.BeginTransaction()

at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)

at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)

at System.Data.Entity.Core.Objects.ObjectContext.<>c__DisplayClass2a.b__27()

at System.Data.Entity.Infrastructure.DefaultExecutionStrategy.Execute[TResult](Func`1 operation)

at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)

at System.Data.Entity.Core.Objects.ObjectContext.SaveChanges(SaveOptions options)

at System.Data.Entity.Internal.InternalContext.SaveChanges()

at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()

at System.Data.Entity.DbContext.SaveChanges()

at ###.Account.###.ButtonSubmit###_Click(Object sender, EventArgs e)

at System.Web.UI.WebControls.Button.OnClick(EventArgs e)

at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)

at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.HandleError(Exception e)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest()

at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)

at System.Web.UI.Page.ProcessRequest(HttpContext context)

at ASP.account_###.ProcessRequest(HttpContext context)

at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Exception on creating a user: System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: Nested transactions are not supported.

at MySql.Data.MySqlClient.ExceptionInterceptor.Throw(Exception exception)

at MySql.Data.MySqlClient.MySqlConnection.Throw(Exception ex)

at MySql.Data.MySqlClient.MySqlConnection.BeginTransaction(IsolationLevel iso)

at MySql.Data.MySqlClient.MySqlConnection.BeginTransaction()

at MySql.Web.Security.MySQLMembershipProvider.GetUser(Object providerUserKey, Boolean userIsOnline)

at MySql.Web.Security.MySQLMembershipProvider.GetUser(String username, Boolean userIsOnline)

at MySql.Web.Security.MySQLMembershipProvider.CreateUser(String username, String password, String email, String passwordQuestion, String passwordAnswer, Boolean isApproved, Object providerUserKey, MembershipCreateStatus& status)

at System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser()

at System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e)

at System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e)

at System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e)

at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)

at System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e)

at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument)

at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)

at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.HandleError(Exception e)

at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

at System.Web.UI.Page.ProcessRequest()

at System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context)

at System.Web.UI.Page.ProcessRequest(HttpContext context)

at ASP.register_aspx.ProcessRequest(HttpContext context)

at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Using Entity Framework with MySql and MsSql in the same application issue (no replies)

$
0
0
Yesterday I did migration (EF 5.0 => EF 6.0) of web application that uses entity framework to reach MySql and SQL Server databases (particular DbContext to particular databases, NOT any DbContext to any type of database).

Compile time things were done without any issues, run-time faced me with exception:

The default DbConfiguration instance was used by the Entity Framework before the 'MySqlEFConfiguration' type was discovered.

The [DbConfigurationType(typeof(MySqlEFConfiguration))] attribute on the context appears to have been ignored at run time because the context is in an external assembly(?) and the DbConfiguration used instead is global to the application domain, not the specific to the context(?)."

I tried different approaches to fix it, then googled it and - surprise - find no working solution.

Looks like situation described well formed here http://forums.mysql.com/read.php?174,614148,614148 still not changed, or I missed some obvious things.

Any feedback will be appreciated.

Thank you in advance!

DETAILED DESCRIPTION:

Input (simplified): - ASP.NET Web Application

Data access layer implemented over Entity Framework 6.1.1

Entity Framework providers:

System.Data.SqlClient 6.1.1

MySql.Data.MySqlClient 6.9.4

MY_SqlContext, model first concept, targeted to MY SQL Server database

Ms_SqlContext, database first concept, targeted to MS SQL Server database

According generic documentation of Entity Framework 6 and MySql Connector/Net documentation (http://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html), MY_SqlContext requires MySqlEFConfiguration to be applied.

According both documentations, refered above, there are three options to do that. All three was tried and failed.

Option 1: Adding the DbConfigurationTypeAttribute [DbConfigurationType(typeof(MySqlEFConfiguration))] to MY_SqlContext class

Appropriate Web.config segments:

<connectionStrings>
<add name="MY_SqlContext"
connectionString="server=.;User Id=root;password=...;Persist Security Info=True;database=MySqlDb;Use Compression=False;Use Old Syntax=False"
providerName="MySql.Data.MySqlClient" />
<add name="Ms_SqlContext"
connectionString="metadata=res://*/Ms_SqlContext.csdl|res://*/Ms_SqlContext.ssdl|res://*/Ms_SqlContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=MsSqlDb;User ID=appuser;Password=...&quot;"
providerName="System.Data.EntityClient" />
</connectionStrings>

<entityFramework>
<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>
</entityFramework>
After application start and web requests begin processing:

Ms_SqlContext works ok Trying create MY_SqlContext instance exception: "The default DbConfiguration instance was used by the Entity Framework before the 'MySqlEFConfiguration' type was discovered. An instance of 'MySqlEFConfiguration' must be set at application start before using any Entity Framework features or must be registered in the application's config file. See ...LinkId=260883 for more information."

Option 2: Calling DbConfiguration.SetConfiguration(new MySqlEFConfiguration()) at the application startup

Appropriate Web.config segments (same as Option 1, actually):

<connectionStrings>
<add name="MY_SqlContext"
connectionString="server=.;User Id=root;password=...;Persist Security Info=True;database=MySqlDb;Use Compression=False;Use Old Syntax=False"
providerName="MySql.Data.MySqlClient" />
<add name="Ms_SqlContext"
connectionString="metadata=res://*/Ms_SqlContext.csdl|res://*/Ms_SqlContext.ssdl|res://*/Ms_SqlContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=MsSqlDb;User ID=appuser;Password=...&quot;"
providerName="System.Data.EntityClient" />
</connectionStrings>

<entityFramework>
<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>
</entityFramework>
Code, added to Global.asax.cs: private void Application_Start(object sender, EventArgs e) { DbConfiguration.SetConfiguration(new MySqlEFConfiguration()); ... After application start and web requests begin processing:

Trying create Ms_SqlContext instance exception: An instance of 'MySqlEFConfiguration' was set but this type was not discovered in the same assembly as the 'Ms_SqlContext' context. Either put the DbConfiguration type in the same assembly as the DbContext type, use DbConfigurationTypeAttribute on the DbContext type to specify the DbConfiguration type, or set the DbConfiguration type in the config file. See ...?LinkId=260883 for more information.

Option 3: Set the DbConfiguration type in the configuration file

Appropriate Web.config segments

<connectionStrings>
<add name="MY_SqlContext"
connectionString="server=.;User Id=root;password=...;Persist Security Info=True;database=MySqlDb;Use Compression=False;Use Old Syntax=False"
providerName="MySql.Data.MySqlClient" />
<add name="Ms_SqlContext"
connectionString="metadata=res://*/Ms_SqlContext.csdl|res://*/Ms_SqlContext.ssdl|res://*/Ms_SqlContext.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.;initial catalog=MsSqlDb;User ID=appuser;Password=...&quot;"
providerName="System.Data.EntityClient" />
</connectionStrings>

<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
<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>
</entityFramework>
After application start and web requests begin processing: ... Ms_SqlContext instance created, but during first query execution exception: EntityException: {"The underlying provider failed on Open."} InnerException: {"Unable to connect to any of the specified MySQL hosts."} So, Ms_SqlContext get MySql configuration that is obviously wrong.

Connection Attributes (no replies)

$
0
0
Hi, I'd like to specify custom attributes in my Connection Attributes, which will be very useful for Performance Scheme related diagnostics etc.
I notice on the documentation there's mention of "Connect_Attrs", however they seem to be unmentioned anywhere in the code. And attempting to set that settings causes this error

System.ArgumentException: Keyword not supported.
Parameter name: connect_attrs
at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.GetOption(String key)
at MySql.Data.MySqlClient.MySqlConnectionStringBuilder.set_Item(String keyword, Object value)
at System.Data.Common.DbConnectionStringBuilder.set_ConnectionString(String value)
at MySql.Data.MySqlClient.MySqlConnectionStringBuilder..ctor(String connStr)


May I recommend these additions (Taken from 6.9.4's latest source)


MySqlConnectionStringBuilder.cs @ line 190
+ options.Add(new MySqlConnectionStringOption("connectattrs", "connect_attrs,connection attributes", typeof(string), "", false));


MySqlConnectionStringBuilder.cs @ line 688
+[Category("Advanced")]
+[DisplayName("Connection Attributes")]
+[Description("A Comma separated <key>:<value> list of extra connection attributes")]
+public string ConnectionAttributes
+{
+ get { return (string)values["connectattrs"]; }
+ set { SetValue("connectattrs", value); }
+}


NativeDriver.cs @ line 931
+//Now join in some custom attributes
+if (owner.Settings.ConnectionAttributes != null)
+{
+ string[] attributes = owner.Settings.ConnectionAttributes.Split(new char[] {','}, StringSplitOptions.RemoveEmptyEntries);
+ string[] attributePair;
+ foreach (string attributeKeyValue in attributes) {
+ attributePair = attributeKeyValue.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
+ if (attributePair.Length == 2)
+ {
+ connectAttrs += string.Format("{0}{1}", (char)attributePair[0].Length, attributePair[0]);
+ connectAttrs += string.Format("{0}{1}", (char)attributePair[1].Length, attributePair[1]);
+ }
+ }
+}

Using a cursor inside a stored procedure to populate normalized tables (no replies)

$
0
0
Hi

I am trying to populate volume data using a stored procedure.

I have a parent table which has a primary key as auto increment.The parent has about 4 normalized child tables with a one to many relation between them. The parent table primary key is a foreign key for this table

Because i need to insert the parent record, get the primary key and then use that as a foreign key for this child records the approach that first came to mind is

Create a cursor which loops around the staging table

Inserts 1 record into the parent table
Select select LAST_INSERT_ID() into a variable
Then insert into all the child tables using the parent table Id for foreign key.

This is repeated in a loop.

I am though having some serious performance issues. I am working with a sample data set for development which is about 10k parent records and maybe as many child records/table for now.

Any advice? I have tried similar approaches in other databases and have never encountered this performance issues.

Any alternative approach would be appreciated.

Regards

Sid

using Singleton to control database access (no replies)

$
0
0
I have a Windows app that I'm writing (desktop application) that has several objects (it's being written in C#), and each object needs to access the database somewhow to both read and write data.

What I'm wondering is if I should have a common database object that is accessed by each object, so that there is (technically) only one database connection per client machine (or at least, per instance of the program being run), or should I Have a separate database connection object for each object within the program (Object meaning that I'm writing an add-on for an accounting system, so my objects would be things like SAles Order, Shipment, Serial Number, etc).

I thought about using the Singleton pattern in each of the objects to control database access connections, but the problem is that there are cases where I may need to create a few instances of a particular object/class, but I only want one instance to be able to access the database at a time, and ideally, one connection among all objects in existance, regardless of what type they are (Sales ORder, Serial Number, Shipment, etc).

Suggestions?

mysqlparameter not in connector 6.9.x (no replies)

$
0
0
Hi All,

Im working with mysql 5.6 and .net connector 6.8.3. With EF 6. Sone of of the data access method use dynamic sql and I pass parameters using mysqlparameter and objectparameter dies not work. Everything wirks fine. Now upgrade to .net connector 6.9.3. Mysqlpaeameter is gone from the connector dll.

I try objectparameter but doesnt work. Anybody has any idea on how to use parameter with connector 6.9.3?

Thx

Kevin

SimpleRoleProvider.cs bug (no replies)

$
0
0
From source code net connector 6.9.4 (6.9.3 too)
SimpleRoleProvider.cs

===============
internal int GetRoleId(string role)
{
using (MySqlDatabaseWrapper dbConn = new MySqlDatabaseWrapper(GetConnectionString()))
{
var roleid = dbConn.ExecuteQuerySingleRecord(string.Format("select roleid from {0} where rolename=?;", _rolesTable), role);
if (role != null)
return (int)role[0];

return 0;
}
}
=================

¿Maybe return (int)roleid[0]?

Now MySqlSimpleRoleProvider.RoleExists("rolename") is ALWAYS true
Viewing all 1447 articles
Browse latest View live