Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6532253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:58:40+00:00 2026-05-25T09:58:40+00:00

I have a WPF application in which I’m trying to use Entity Framework 4.1

  • 0

I have a WPF application in which I’m trying to use Entity Framework 4.1 Code First for Data Access Logic. I’m using MySQL as DBMS. For simplicity I have created just one data class User:

public class User
{
    [Key]
    [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
    public int Id { get; set; }

    [Required]
    [MaxLength(50)]
    public string Name { get; set; }

    [Required]
    [MaxLength(50)]
    public string Surname { get; set; }

    [Required]
    [MaxLength(50)]
    public string Username { get; set; }

    [Required]
    [MaxLength(255)]
    public string Password { get; set; }
}

And I have an ApplicationContext class extending the DbContext like:

public class ApplicationContext : DbContext
{
    public ApplicationContext()
        : base()
    {
    }

    public DbSet<User> Users;
}

I add a connection string with the name ApplicationContext to the app.config file.

<configuration>
    <connectionStrings>
        <clear/>
        <add name="ApplicationContext" 
 connectionString="server=localhost;User Id=myuser;Password=mypassword;Persist Security Info=True;database=mydatabase" 
 providerName="MySql.Data.MySqlClient"/>
    </connectionStrings>
    <system.data>
        <DbProviderFactories>
            <remove invariant="MySql.Data.MySqlClient" />
            <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
 description=".Net Framework Data Provider for MySQL" 
 type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.4.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
        </DbProviderFactories>
    </system.data>
</configuration>

And when I try to initialize the database with the following code inside the App.xaml.cs file OnStartup method, I get ProviderIncompatibleException saying The provider did not return a ProviderManifestToken string. And the inner exception says Unknown database.

Database.SetInitializer<ApplicationContext>(
    new DropCreateDatabaseIfModelChanges<ApplicationContext>());

this.AppDatabaseContext = new ApplicationContext();
this.AppDatabaseContext.Database.Initialize(true);

I think it tries to connect to the database with the database name I have provided in the connection string and fails since it does not exist. However, I expect that it should create one if there isn’t already.

I also tried to create the database by hand from MySQL and re-run the application, this time I get a different type of exception: NotSupportedException saying Model compatibility cannot be checked because the database does not contain model metadata. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions

I have searched the internet and tried many things to overcome this problem but couldn’t find a solution.

Any help will be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:58:41+00:00Added an answer on May 25, 2026 at 9:58 am

    It could be a problem with the version of the ado.net provider for MySQL that you are using.

    The latest version of dotconnect for MySQL supports code-first for EF 4.1, see http://www.devart.com/news/2011/dotconnects630.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple WPF application in which I am using data binding
I have a simple WPF application which I am trying to start. I am
Please help! Background info I have a WPF application which accesses a SQL Server
I have a WPF application using Aero Glass. When using the application under a
I have a WPF application in VS 2008 with some web service references. For
I have a WPF application that runs fine under XP as an administrator. When
I have written a WPF application that I want to port to Silverlight 2.
I have a simple WPF application with a menu. I need to add menu
I have a simple message box in a WPF application that is launched as
I have a FlowDocument in a standard WPF application window where I have some

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.