Debugging error ASP.NET Web Api Project with Visual Studio For Mac

123 views Asked by At

I have downloaded Visual Studio For Mac and pulled my working copy of my project into mac. It automatically restored the nuget packages and started debugging successfully by showing Asp.NET Web API default page.

However the problem starts on here. In project we are using Asp.Net Identity to authenticate/authorize to server therefore it's checked on "GrantResourceOwnerCredentials" on OAuthApplicationProvider just like below.

public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
    {
        try
        {
            var userManager = context.OwinContext.GetUserManager<ApplicationUserManager>();

            var user = await userManager.FindAsync(context.UserName, context.Password);

            if (user == null || !user.IsActive)
            {
                context.SetError("invalid_grant", "The user name or password is incorrect.");
                return;
            }

            var oAuthIdentity = await user.GenerateUserIdentityAsync(userManager,
               OAuthDefaults.AuthenticationType);
            var cookiesIdentity = await user.GenerateUserIdentityAsync(userManager,
                CookieAuthenticationDefaults.AuthenticationType);
            var properties = CreateProperties(user.UserName);
            var ticket = new AuthenticationTicket(oAuthIdentity, properties);
            context.Validated(ticket);
            context.Request.Context.Authentication.SignIn(cookiesIdentity);

        }catch(Exception ex){
            throw ex;
        }

    }

In this method userManage.FindAsync throws an error just only on ** Visual Studio for Mac** saying that

System.InvalidOperationException: The 'CreateDate' property on 'User' could not be set to a 'System.String' value. You must set this property to a non-null value of type 'System.DateTimeOffset'.

enter image description here

As I said I have tested the same working copy debugging with normal Visual Studio via Parallels and that is working. In addition to this I've made a research about the thrown error. It is something about Sql Conversion however the database is the same while debugging with Visual Studio 2017. How can I resolve this problem and start working over Visual Studio for Mac ?

0

There are 0 answers