Asp.Net MVC + Nhibernate Issue after add a new column in SQL and try for add/update operations

42 views
Skip to first unread message

Koti

unread,
Feb 1, 2021, 11:26:24 AM2/1/21
to nhusers
Hello Group,

Could any one help/guide me on the below Issue.

1) I have tried creating the new column using Sql -> Table Design -> Add New Column
2) I have tried creating the new column using FluentMigrator (See the code below)

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() {
                    }
}
}
I have executed the application by Clean/Rebuild the Solution but every time I'm experiencing the below exception

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)

I'm really looking for some help on this.

Thanks In Advance
Koti

Oskar Berggren

unread,
Feb 1, 2021, 11:48:19 AM2/1/21
to nhusers
Hi,

I feel like you kind of skipped over something there - you say you "tried creating", even by manual action in GUI, and you get an exception from runtime about invalid column name. But do you actually have the column in the (correct) table in the (correct) database or not? In other words - is the problem that for some reason neither of the two methods you tried succeed in creating the column, or is the problem that querying the table isn't working despite the column actually being present when you check with the tools of the database server itself?

bala koti

unread,
Feb 6, 2021, 6:11:38 AM2/6/21
to nhu...@googlegroups.com
Hi, 

The problem is with the Table which is referring to  is different.
I am able to find it using NHibernate.SQL Logs and corrected the issue.

Thanks for your help

Koti
--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nhusers+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nhusers/168501d6-d414-471b-975c-ba23004830f9n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages