TIMESTAMP(7) with Time Zone to DateTimeOffset? System.InvalidCastException: Specified cast is not valid.

TIMESTAMP(7) with Time Zone to DateTimeOffset? System.InvalidCastException: Specified cast is not valid.

Postby trand » Wed 15 Feb 2017 23:54

Hi,

I am implementing ASP.NET IDENTITY with Oracle 12C and using the following versions:

1. Microsoft.AspNetCore.Identity.EntityFrameworkCore: 1.1.0
2. dotConnect for Oracle Developer version 9.2.205

When one of the columns (LOCKOUT_END) in Table ASPNET_USERS contains a value it is unable to map to the entity class and throws the following exception: System.InvalidCastException: Specified cast is not valid.

The column type for LOCKOUT_END is TIMESTAMP(7) WITH TIME ZONE and the Model property is of type DateTimeOffset?

Is this not supported?

Thanks in advance
trand
 
Posts: 3
Joined: Wed 15 Feb 2017 21:00

Re: TIMESTAMP(7) with Time Zone to DateTimeOffset? System.InvalidCastException: Specified cast is not valid.

Postby Shalex » Mon 20 Feb 2017 16:16

dotConnect for Oracle supports ASP.NET Identity 2.0 with EF6: https://www.devart.com/dotconnect/oracle/docs/?Identity-2-Tutorial-Entity.html.

If this is not the case, please specify the version of ASP.NET Identity you are using.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: TIMESTAMP(7) with Time Zone to DateTimeOffset? System.InvalidCastException: Specified cast is not valid.

Postby trand » Tue 21 Feb 2017 17:29

Shalex wrote:dotConnect for Oracle supports ASP.NET Identity 2.0 with EF6: https://www.devart.com/dotconnect/oracle/docs/?Identity-2-Tutorial-Entity.html.

If this is not the case, please specify the version of ASP.NET Identity you are using.


Hi Shalex,

I am using ASP.NET Identity Core 1.1.0 with Entity Framework Core 1.1.0.

Thanks,
David
trand
 
Posts: 3
Joined: Wed 15 Feb 2017 21:00

Re: TIMESTAMP(7) with Time Zone to DateTimeOffset? System.InvalidCastException: Specified cast is not valid.

Postby Shalex » Tue 28 Feb 2017 18:46

We will investigate the question and notify you about the result as soon as possible.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: TIMESTAMP(7) with Time Zone to DateTimeOffset? System.InvalidCastException: Specified cast is not valid.

Postby Shalex » Fri 03 Mar 2017 16:01

We are working on the walkthrough how to use ASP.NET Core Identity with Devart provider.

trand wrote:When one of the columns (LOCKOUT_END) in Table ASPNET_USERS contains a value it is unable to map to the entity class and throws the following exception: System.InvalidCastException: Specified cast is not valid.
Could you please tell us the exact steps we should follow to reproduce the error in our environment?
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: TIMESTAMP(7) with Time Zone to DateTimeOffset? System.InvalidCastException: Specified cast is not valid.

Postby trand » Fri 03 Mar 2017 21:56

Shalex wrote:We are working on the walkthrough how to use ASP.NET Core Identity with Devart provider.

trand wrote:When one of the columns (LOCKOUT_END) in Table ASPNET_USERS contains a value it is unable to map to the entity class and throws the following exception: System.InvalidCastException: Specified cast is not valid.
Could you please tell us the exact steps we should follow to reproduce the error in our environment?


If LOCKOUT_END in table ASPNET_USERS has a value then you will receive an error. The easiest way to generate a value in LOCKOUT_END is to:

1. update a specific user record and set the LOCKOUT_END to a value in the future
2. Attempt to login with that same user
3. you will get a cast error

Alternatively you can generate a value for LOCKOUT_END by logging in with an account multiple times with a WRONG password until LOCKOUT_END generates a value (this usually occurs 5 times by default). This is done by ensuring and running the following ...

1. Make sure lockoutOnFailure is set to true and use this in your login controller action

var result = await _signInManager.PasswordSignInAsync(loginViewModel.username, loginViewModel.Password, loginViewModel.RememberMe, lockoutOnFailure: true);

2. Sign in with the wrong password multiple times. The column ACCESS_FAILED_COUNT will increment and once it reaches 5 it will lock the account by setting the LOCKOUT_END field.

3. you will get a cast error
trand
 
Posts: 3
Joined: Wed 15 Feb 2017 21:00

Re: TIMESTAMP(7) with Time Zone to DateTimeOffset? System.InvalidCastException: Specified cast is not valid.

Postby Shalex » Mon 06 Mar 2017 11:58

Thank you for the details. We will notify you about the result of our investigation.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Re: TIMESTAMP(7) with Time Zone to DateTimeOffset? System.InvalidCastException: Specified cast is not valid.

Postby Shalex » Fri 26 May 2017 20:06

The compatibility with ASP.NET Core Identity is improved in the new version dotConnect for Oracle 9.4: http://forums.devart.com/viewtopic.php?f=1&t=35436.

Simple walkthrough with a new version:

* create File > New > Project > Installed > Visual C# > Web > ASP.NET Core Web Application (.NET Core), select Web Application and set Authentication: Individual User Accounts

* run via Package Manager Console
PM> install-package Devart.Data.Oracle.EFCore

* replace
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
with
options.UseOracle(Configuration.GetConnectionString("DefaultConnection")));
in Startup.cs

* set your DefaultConnection for Oracle in appsettings.json

* execute via Package Manager Console
PM> update-database
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44


Return to dotConnect for Oracle