Be careful using connector .net, Connector 6.6.5 have a bug, it is not working for inserting tinyint values as identity, for example:
create table person(
Id tinyint unsigned primary key auto_increment,
Name varchar(30)
);
if you try to insert an object like this:
Person p;
p = new Person();
p.Name = 'Oware'
context.Person.Add(p);
context.SaveChanges();
You will get a Null Reference Exception:
Referencia a objeto no establecida como instancia de un objeto.:
en MySql.Data.Entity.ListFragment.WriteSql(StringBuilder sql)
en MySql.Data.Entity.SelectStatement.WriteSql(StringBuilder sql)
en MySql.Data.Entity.InsertStatement.WriteSql(StringBuilder sql)
en MySql.Data.Entity.SqlFragment.ToString()
en MySql.Data.Entity.InsertGenerator.GenerateSQL(DbCommandTree tree)
en MySql.Data.MySqlClient.MySqlProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree)
en System.Data.Common.DbProviderServices.CreateCommandDefinition(DbCommandTree commandTree)
en System.Data.Common.DbProviderServices.CreateCommand(DbCommandTree commandTree)
en System.Data.Mapping.Update.Internal.UpdateTranslator.CreateCommand(DbModificationCommandTree commandTree)
en System.Data.Mapping.Update.Internal.DynamicUpdateCommand.CreateCommand(UpdateTranslator translator, Dictionary`2 identifierValues)
en System.Data.Mapping.Update.Internal.DynamicUpdateCommand.Execute(UpdateTranslator translator, EntityConnection connection, Dictionary`2 identifierValues, List`1 generatedValues)
en System.Data.Mapping.Update.Internal.UpdateTranslator.Update(IEntityStateManager stateManager, IEntityAdapter adapter)
en System.Data.EntityClient.EntityAdapter.Update(IEntityStateManager entityCache)
en System.Data.Objects.ObjectContext.SaveChanges(SaveOptions options)
en System.Data.Entity.Internal.InternalContext.SaveChanges()
en System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
en System.Data.Entity.DbContext.SaveChanges()
Until now I haven't found a solution, I had to change my tinyint identity to unsigned int identity, this solved the problem but this is not the right solution.
If you use an older version of Connector.net (I used 6.4.4) you won't have this problem.
If someone knows about the solution, please contact me.
Cheers!
Oware