Reputation: 2510
I am at a loss with this one. First of all, something strange:
every time I open a connection, (as shown in mysql logs), the following commands are excecuted:
SET character_set_results=NULL
SET NAMES utf8
SHOW COLLATION
SHOW VARIABLES
Then there is no select query at all!
A simple:
using (MyEntities myents = new MyEntities())
{
var lala = (from r in myents.categories
select r).ToList();
}
Will produce an error: Object reference not set to an instance of an object.
Even a .FirstOrDefault() produces the same error! (it should return null in case of empty dataset).
I think I broke asp.net!
Asp.net ver 4 MySQL connector 6.4.3 MVC 3 controller (same result is also inside a repository class etc)
Upvotes: 1
Views: 293
Reputation: 2510
Looks like I found the cause of mayhem, but why this bug occurs beats me: (evil) NUGET added this:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
[...]
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.4.3.0" newVersion="6.4.3.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Deleting this from the config makes everything fine and dandy!
Upvotes: 0
Reputation: 5002
Have you specified the ConnectionString
correctly in the top level Web.config
or App.config
(i.e. the one that features the above code)?
Debug and try to find out if it's your MyEntities
that is null
or something else.
Upvotes: 1