I've got a project where I'm moving data from database to another. I've got several tables working but the current one isn't. When calling the Session.Save(entity)
nothing appears to occur (no insert record being sent from NHibernate). The entities that aren't saving are the Configuration
ones in code below. I'm included other code related to another entity which is working fine (about a dozen are). Data is going from an Access database to a MSSQL database.
Code that copies object and performs the session save. Nothing is inserted when save is called on Configuration
entity.
public void Save(Entities.Access.CompTool o)
{
var n = new CompTool();
n.Name = o.Name;
n.Description = o.Description;
n.DefaultLocation = o.DefaultLocation;
n.DateModified = o.DateModified;
n.OldId = o.Id;
GetSession().Save(n);
}
public void Save(Entities.Access.Configuration o)
{
var n = new Configuration();
n.Name = o.Name;
n.Description = o.Description;
n.Value = o.Value;
GetSession().Save(n);
}
Mapping Configuration
using TestProg.DatabaseConverter.Entities.Sql;
using FluentNHibernate.Mapping;
namespace TestProg.DatabaseConverter.Mappings.Sql
{
public class ConfigurationMap : ClassMap<Configuration>
{
public ConfigurationMap()
{
Table("Configuration");
Id(x => x.Name).GeneratedBy.Assigned();
Map(x => x.Value);
Map(x => x.Description).Column("Desription");
}
}
}
Mapping CompTool
using TestProg.DatabaseConverter.Entities.Sql;
using FluentNHibernate.Mapping;
namespace TestProg.DatabaseConverter.Mappings.Sql
{
public class CompToolMap: ClassMap<CompTool>
{
public CompToolMap()
{
Table("CompTools");
Id(x => x.Id).Column("ID");
Map(x => x.Name);
Map(x => x.Description);
Map(x => x.DefaultLocation);
Map(x => x.DateModified);
Map(x => x.OldId);
}
}
}
Configuration
entity
using System;
namespace TestProg.DatabaseConverter.Entities.Sql
{
public class Configuration
{
public virtual string Name { get; set; }
public virtual string Value { get; set; }
public virtual string Description { get; set; }
}
}
Code to create Configuration
table:
CREATE TABLE Configuration
(
Name nvarchar(50) PRIMARY KEY,
Value nvarchar(50) DEFAULT '',
Desription nvarchar(100) DEFAULT ''
)