NHibernate SqlDateTime Exception Overflow Exception Exception Exceptional

I map a very simple "Users" table, and I have a column called "LastLoginDate", which is defined as nullable on the sql server.

My mapping is as follows:

public Users { Id(x => x.UserId); Map(x => x.UserName); ... ... Map(x => x.LastLoginDate).Nullable(); } 

But every time I try to save this entity programmatically, I always get a SqlDateTime overflow exception. If I try to enter the sql statement manually with 'null' in this column, this will work. If I comment on this property, it will also work.

What could be the problem???

Thanks in advance!

+4
source share
1 answer

Your face should look like this:

 public class User { public virtual DateTime? LastLoginDate {get;set;} // etc } 

Then your card should work correctly.

edit ? after DateTime indicates that it is Nullable, and is a short form for Nullable<DateTime> . If this is not the cause of your error, you can verify that Fluently.Configure is indicating the correct version of SqlServer.

+12
source

Source: https://habr.com/ru/post/1307884/


All Articles