Does EF fully support ANY cross-platform database?

For past few hours, I tried to "port" my current project from Sql Server to MySQL, I ended up with errors like:

The underlying provider does not support the type varchar(max) (or uniqueidentifier, or something else)

I use POCO, and Code First - I thought, that one of the purposes of EF was to provide easy repository "switching", but it would seam that even basic types are not mapped correctly :/

I also tried SQlite but it is even in worst shape, and as far as I know, Postrage SQL support is also lacking.

So... question is - is there any cross-platform (preferably free) database out there that has real (SQL Server like) support in EF?

Thanks in advance.

Best regards.

Edit:

To by more specific about my approach:

I use POCO, and Code First, I want to automatically create the database if it doesn't exists, I don't use anything special inside my POCO classes, just standard .NET types. Example POCO looks like this:

[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int ID { get; set; }

[Required]
[StringLength(128)]
public string Name { get; set; }

[Required]
public int AgencyID { get; set; }

[Required]
public bool IsEnabled { get; set; }

#region NavigationProperties

[NavigationProperty]
public virtual Agency Agency { get; set; }

#endregion

Edit2:

My app.config looks like this:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <entityFramework>
    <!--<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    </providers>-->
    <defaultConnectionFactory type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data" />
  </entityFramework>
</configuration>

Answers


You seem to have SqlServer set as your defaultConnectionFactory in the app/wbeb.config file which results in EF using SqlServer types. You need to set the defaultConnectionFactory to a MySQL connection factory.


I struggled with this same error all night. The fix was counter-intuitive but so far so good... It does seem that the issue had to do with old migrations that were set up with LocalDB (SQL Server) yet even deleting the old migrations had no effect. I also spent lots of unnecessary time fiddling with my Web.config, Database Context, etc... I suggest trying the following before banging your head on the wall...

  1. Delete the migrations folder
  2. Try enabling migrations and adding your initial migration (in the PM type "enable-migrations" and then "add-migration init")
  3. If you get the above error in the PM, delete the migrations folder again, then open up MySQL Workbench
  4. Within MySQL Workbench, locate the Schema with the name you gave in your connectionString (will look like database=whateverYouCalledIt)
  5. In that schema, open the tables and find "__migrationhistory"
  6. Right click that table, click select rows, and delete any existing migration entries, then repeat step 2

For some reason this did the trick for me when deleting migrations in the solution explorer had no effect. Apparently, that didn't delete the migration history in the database...

And for the record to the OP, this worked just fine with ASP.net Identity and the MVC Auth system... I think SimpleMembership is now antiquated but then I'm not developing desktop apps...


Need Your Help

Silverlight change color custom control programatically

c# silverlight

I have this Ellipse which I turned into a custom control so i could animate it programatically. However I am having trouble changing it's color.

Exclusion paths on a UILabel's TextContainer

ios iphone objective-c uitableview textkit

Is it possible to set exclusion paths on a UILabel? The apple documentation states that UILabel is now built upon TextKit but a UILabel does not seem to expose a textContainer property.