Please help me with the below issue.
I have added a new column to Existing Table and Rebuild the code and It works fine when reading a record.
public TEntity Get(int id) {
Session.CacheMode = CacheMode.Normal;
var entity = Session.Get<TEntity>(id);
return entity;
}
While Saving the changes I'm getting the below exception
public bool Update(TEntity entity)
{
Session.Transaction.Begin();
Session.SaveOrUpdate(entity);
Session.Flush();
Session.Transaction.Commit(); (Exception at this line)
return true;
}
Exception Details:
Message: could not execute batch command.[SQL: SQL not available]
Inner Exception: {"Invalid column name 'UseTerms'."}
Stack Trace:
at NHibernate.Engine.ActionQueue.BeforeTransactionCompletionProcessQueue.BeforeTransactionCompletion()
at NHibernate.Impl.SessionImpl.BeforeTransactionCompletion(ITransaction tx)
at NHibernate.Transaction.AdoTransaction.Commit()
at WebApp.Core.Data.NHibernateData.Repositories.NHibernateRepository`1.Update(TEntity entity) in D:\WebApp\Core\WebApp.Core.Data.NHibernateData\Repositories\NHibernateRepository.cs:line 55
at WebApp.Core.Logic.Configuration.GroupConfigurationLogic.SaveGroupConig[TEntity,TDto](Int32 groupId, IRepository`1 repository, TDto dto) in D:\WebApp\Core\WebApp.Core.Logic\Configuration\GroupConfigurationLogic.cs:line 63
at WebApp.Core.Logic.Configuration.ConfigurationService.SaveGroupConfiguration(GroupConfigurationDto groupConfiguration, Guid updatedBy) in D:\WebApp\Core\WebApp.Core.Logic\Configuration\ConfigurationService.cs:line 91
at WebApp.Core.Wcf.ConfigurationService.SaveGroupConfiguration(GroupConfigurationDto groupConfiguration, Guid updatedBy) in D:\WebApp\Core\WebApp.Core.Wcf\ConfigurationService.svc.cs:line 24
at SyncInvokeSaveGroupConfiguration(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
What I have tried:
I have tried 2 Ways to Create a New Column
1) Open the designer and create a new column in Sql (which results the same exception)
2) Using FluentMigrator Up Method I have created a new column (Column is created and after recompile and execute the application - same exception is resulting)
using FluentMigrator;
namespace WebApp.Core.Migrations.Release7_21
{
[Migration(202006082020, "AchConfiguration Migration")]
public class AchConfigurationMigration : Migration
{
public override void Up() {
Create.Column("UseTerms").OnTable("AchConfiguration").InSchema("config")
.AsBoolean().NotNullable().WithDefaultValue(1);
}
public override void Down() {
}
}
}