0

I am new to ASP.NET if someone could explain why this doesn't work or how to set it up correctly would be great

This code:

    [HttpPost]
    public string Post([FromBody] User account)
    {
        Accounts newAccount = new Accounts { FirstName = account.FirstName, LastName = account.LastName, 
            Email = account.Email, Username = account.Username, Password = account.Password };

        using (AccountsDbEntities entities = new AccountsDbEntities())
        {
            entities.Account.Add(newAccount);
            entities.SaveChanges();
        }

        return "Success";
    }

Is returning this error:

System.ArgumentException: 'The ADO.NET provider with invariant name 'System.Data.SqlClient' is either not registered in the machine or application config file, or could not be loaded. See the inner exception for details.'

For this line: entities.Account.Add(newAccount);

I am using ASP.NET Core 2.1 with ADO.NET Entity

Is my code wrong or is it configuration?

  • Related - [Entity Framework ADO.NET Sql.Data.Client provider not found](https://stackoverflow.com/questions/20111583/entity-framework-ado-net-sql-data-client-provider-not-found) – Anoop R Desai Jan 26 '20 at 15:53
  • I tried all of that, I've tried everything installing additional packages, removing from machine.config, adding to web.config and app.config nothing works – fawosor936 Jan 26 '20 at 16:05

0 Answers0