D
D
David Sedrakyan2016-09-09 15:23:42
MySQL
David Sedrakyan, 2016-09-09 15:23:42

How to connect .net mvc to mysql server via connectionstrings?

I have this ConnectionString

<connectionStrings>
    <add name="conn" providerName="MySql.Data.MySqlClient"
        connectionString="server=localhost;UserId=root;Password=;database=testapi;CharSet=utf8_general_ci;Persist Security Info=True" />
  </connectionStrings>

and I get this error localhost:52523/Api/Values ​​Failed to load resource: the server responded with a status of 500 (Internal Server Error)
On this method
public IEnumerable<Test> GetTests()
        {
            return context.Tests;
        }

and accordingly Json which works with the method
function GetAllTests() {

        $("#createBlock").css('display', 'block');
        $("#editBlock").css('display', 'none');
        $.ajax({
            url: '@Url.Action("Values","Api")',
            type: 'GET',
            dataType: 'json',
            success: function (data) {
                WriteResponse(data);
            }
        });
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
David Sedrakyan, 2016-09-09
@PrimeSedrakyan

Found a solution, it was necessary to migrate the database through enable-migrations, add-migration, update-database

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question