How to deploy an ASP.NET Web app (using MySQL) to Azure App Center?


I am a total newbie so please forgive me if my questions are dumb. I am learning how to create a web app using ASP.NET. I created a simple Web App using MySQL for creating my database. The app worked perfectly on my local machine. It's an app where users can create a Task, and the data of that task will be store to a database using MySQL.

The next step is to deploy the app into Azure App Service, just for learning purpose. I used the Publish functionality in Visual Studio 2019 to publish my app. After creating resource group, service plan, ... I hit the publish button. This is where the issues start. I got an error message like following:

Could not load file or assembly 'MySql.Data, Version=, Culture=neutral, >PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition >does not match the assembly reference. (Exception from HRESULT: 0x80131040)

I had referenced MySql.Data assembly in my local machine, but the Version is different from the error message. The PublicKey Token is the same. I had all the SQL assemblies coppied to local. Are they deployed to App Center? Why is App Center asking me for the same Assembly but with different Version number? How can I get the correct assemblies published?

I have done my research and seen some tutorials on how to deploy an app using MySql on Azure App Center. They all added a Azure Database for MySQL. Is it compulsory to do this?

To help you understand what I did better, the following is my connection strings settings:

    <add name="TodolDbContext" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=3306;database=todomysqldb1;uid=root;password=mypassword" />

<entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6">
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
        <parameter value="TodoDbContext" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" /> <!--Version=, Culture=neutral, PublicKeyToken=c5687fc88969c44d"></provider>-->

And here is my context class:

    public class TodoDbContext : DbContext
        public TodoDbContext() : base("server=localhost;port=3306;database=todomysqldb1;uid=root;password=mypassword")

        public DbSet<Todo> Todos { get; set; }

        protected override void OnModelCreating(DbModelBuilder modelBuilder)

What did I do wrong? How can I get my deployed app run in Azure App Center?

asked on Stack Overflow Feb 15, 2020 by thai

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0