Microsoft.EntityFrameworkCore 2.1-rc with MySql.Data.EntityFrameworkCore - mysql

I'm trying to use mysql with Microsoft.EntityFrameworkCore 2.1-rc-final and MySql.Data.EntityFrameworkCore 8.0.11 as provider. But when I'm trying to execute the mugrations command i get this exception:
System.MissingMethodException: Method not found: 'Void Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory..ctor(Microsoft.EntityFrameworkCore.Diagnostics.IDiagnosticsLogger`1, Microsoft.EntityFrameworkCore.Storage.IRelationalTypeMapper)'.
This is my IDesignTimeDbContextFactory code implementation:
public class DesignLocationFactory:IDesignTimeDbContextFactory<LocationDbContext>
{
public LocationDbContext CreateDbContext(string[] args)
{
var builder = new DbContextOptionsBuilder<LocationDbContext>();
builder.UseMySQL("server=localhost;port=3306;user=***;passsword=***;database=locationdb");
return new LocationDbContext(builder.Options);
}
}
Please how can I fix this or at least some sample of how to use with another providers

Finally, with this provider Pomelo.EntityFrameworkCore.MySql version 2.1.0-rc1-final everything works perfect.
To install it execute the command:
Install-Package Pomelo.EntityFrameworkCore.MySql -Version 2.1.0-rc1-final

I can confirm that 2.1.0-rc1-final resolves this issue. Also, take note of Pomelo's case sensitivity vs Microsoft.EntityFrameworkCore.
Pomelo = UseMySql (Sql)
EntityFrameworkCore = UseMySQL (SQL)
Using Core 2.1
Id Versions
-- --------
Microsoft.AspNetCore.App {2.1.0}
Microsoft.VisualStudio.Web.CodeGeneration.Design {2.1.0}
Microsoft.EntityFrameworkCore.Tools {2.1.0}
Microsoft.NETCore.App {2.1.0}
MySql.Data.EntityFrameworkCore.Design {8.0.11}
MySql.Data.EntityFrameworkCore {8.0.11}
Pomelo.EntityFrameworkCore.MySql {2.1.0-rc1-final}

Related

Primefaces upgrade 8 getScriptsToExecute equivalent

Upgraded application from primefaces 5.3.6 to primefaces 8 version.What would be the equivalent of
getScriptsToExecute method from RequestContext in PrimeFaces.current() instance.
Code in bean class:
final List<String> scriptsToExecute = RequestContext.getCurrentInstance().getScriptsToExecute();
scriptsToExecute.add("script1();");
scriptsToExecute.add("script2();");
scriptsToExecute.add("script3();");
PrimeFaces.current().executeScript("script3();");
Please check the documentation next time: https://primefaces.github.io/primefaces/8_0/#/core/javaAPI and the migration guide: https://github.com/primefaces/primefaces/wiki/Migration-Guide

Error in executing SSIS package using mvc C#

I am working to run/execute SSIS package from my application developed in MVC 5.
The package is developed using Visual studio 2017 data tools.
I have written the following code to run the package
try
{
Application app = new Application();
Package package = null;
package = app.LoadPackage(#"‪C:\Users\EMISDb\Desktop\NEOC\EOC data need\NEOC_ETL\NEOC_ETL\99_Dash_WHO.dtsx", null);
//Excute Package
Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();
if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
{
foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
{
Console.WriteLine("Package Execution results: {0}", local_DtsError.Description.ToString());
Console.WriteLine();
}
}
}
catch (DtsException ex)
{
throw;
}
but when i run, it gives the following error message. I tried to find 64 bit but could not find to install. Any help please.
**Retrieving the COM class factory for component with CLSID {4F0FC44B-C99C-441D-B86A-D60D7E22143D} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).**
and
**An Integration Services class cannot be found. Make sure that Integration Services is correctly installed on the computer that is running the application. Also, make sure that the 64-bit version of Integration Services is installed if you are running a 64-bit application.** '

MySql EntityFrameworkCore System.TypeLoadException

I am trying to connect my web API to MySql database with this code:
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
string conn_string = "server=server;database=database;uid=uid;pwd=pwd;";
MySqlConnection conn = new MySqlConnection(conn_string);
services.AddDbContext<TaskContext>(options =>
{
options.UseMySQL(conn);
});
services.AddMvc();
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
app.UseMvc();
}
}
But I always recieve a System.TypeLoadException with this description:
System.TypeLoadException : 'Method 'Clone' in type
'MySQL.Data.EntityFrameworkCore.Infraestructure.Internal.MySQLOptionsExtension'
from assembly 'MySql.Data.EntityFrameworkCore, Version=8.0.8.0,
Culture=neutral, PublicKeyToken=c5687fc88969c44d' does not have an
implementation.'
I am using Microsoft Visual Studio Community 2017 Preview (2) and my projet is in .NET Core 2.0. I also use MySql.Data.EntityFrameworkCore.dll and Microsoft.AspNetCore.All (2.0.0-preview2-final). I have changed many times of librairy for MySql but without success.
Any idea why this always happen? What could be the cause?
Well, it turns out that you can't use MySql.Data.EntityFrameworkCore for .Net Core 2.0(for now). I had to go back to .Net Core 1.3 to make it work... We may be able to use it in a near futur tho!
Use Pomelo.EntityFrameworkCore.MySql 2.0.0.
Works fine for me with .NET Core 2.0
Add "Pomelo.EntityFrameworkCore.MySql" package.
in Stertup.cs & appsettings.json & DbContext :
services.AddDbContext<mvccoreContext>(options =>
options.UseMySql(Configuration.GetConnectionString("DefaultConnection")
));
{
"ConnectionStrings": {
"DefaultConnection": "Server=localhost;Database=mvccore;User=root;Password=;"
},
"Logging": {
"LogLevel": {
"Default": "Warning"
}
},
"AllowedHosts": "*"
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseMySql("");
}
}
MySql.Data.EntityFrameworkCore supports (and is only compatible with) EF Core 2.1. Using mismatched EF Core and DB provider libraries will result in errors similar to the one you reported.
If you need a MySQL EF Core provider that's compatible with EF Core 3.0, your only option right now is the 3.0.0-rc1 version of https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql (see the compatibility table at https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql#compatibility)! ).
Otherwise, if you want to stick with MySql.Data.EntityFrameworkCore you'll need to roll back to EF Core 2.1.

securesocial 3.0 doesn't work with play framework 2.3

1.When i upgrade my play framework from 2.2.6 to 2.3.8 and securesocial from 2.1.4 to 3.0-M3. I got the following error. How to fix it?
[error] /Work/test.scala:81: not found: value SecuredAction
[error] def findStats = SecuredAction {
2.The following line used to work but now it gets an error message:trait SecureSocial takes type parameters.How to fix this?
object ToolbarHandler extends Controller with SecureSocial with CookieLang{
3.Request needs a parameter.How to add the parameter though?
def findStats = SecuredAction {
implicit request =>
You have to use the snapshot version.
As stated here : http://securesocial.ws/guide/getting-started.html
add:
resolvers += "Sonatype OSS Snapshots" at "https://repo.typesafe.com/typesafe/snapshots/"
then add the library dependency:
"ws.securesocial" % "securesocial_2.11" % "master-SNAPSHOT"
Hope that helps.

Fail to run Code-First Migration - RenameColumn - with MySql

I have an issue which I could not find answer for across the web.
I am using CodeFirst EF 4.3.1 Migrations with MySQL.
My MySQL provider is Devart.
After running Add-Migration against an existing database, I got the following code:
public partial class ChangeSet_1231 : DbMigration
{
public override void Up()
{
RenameColumn(table: "RW_TTaskInstanceProperties", name: "TaskInstance_TaskInstanceId", newName: "TaskInstanceId");
}
public override void Down()
{
RenameColumn(table: "RW_TTaskInstanceProperties", name: "TaskInstanceId", newName: "TaskInstance_TaskInstanceId");
}
}
Running Update-Database results in the following error:
PM> Update-Database -verbose –startupprojectname "RTDataAccess"
Using NuGet project 'RTDataAccess'.
Target database is: 'rsruntime' (DataSource: localhost, Provider: Devart.Data.MySql, Origin: Explicit).
Applying explicit migrations: [201205311312361_ChangeSet_1231].
Applying explicit migration: 201205311312361_ChangeSet_1231.
ALTER TABLE RW_TTaskInstanceProperties RENAME COLUMN TaskInstance_TaskInstanceId TO TaskInstanceId
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'COLUMN TaskInstance_TaskInstanceId TO TaskInstanceId' at line 2
From looking at the error details I see that the RenameColumn is translated to a MsSql command, rather than MySql command, so no wonder it reports about a syntax error.
Any ideas how to solve it?
I know I can use Update-Database -script, then edit the script to fit MySql and run it, but I prefer to make the Update-Database command work...
Thanks.
In response to Ladislav's question:
Yes, I registered the Devart's SQL generator for MySQL Migrations.
My Configuration class looks like that:
using Devart.Data.MySql.Entity.Configuration;
using Devart.Data.MySql.Entity.Migrations;
internal sealed class Configuration : DbMigrationsConfiguration<RTDataAccess.RTContext>
{
public Configuration()
{
AutomaticMigrationsEnabled = false;
MySqlEntityProviderConfig.Instance.Workarounds.IgnoreSchemaName = true;
var connectionInfo = MySqlConnectionInfo.CreateConnection("Server=xxxx;Port=yyyy;Database=rsruntime;Uid=zzzz;Pwd=wwww;charset=utf8;");
this.TargetDatabase = connectionInfo;
this.SetSqlGenerator(connectionInfo.GetInvariantName(), new MySqlEntityMigrationSqlGenerator());
}
protected override void Seed(RTDataAccess.RTContext context)
{
}
}
The issue was fixed by Devart.
Details at the following links:
http://forums.devart.com/viewtopic.php?f=2&t=24250
http://www.devart.com/dotconnect/mysql/download.html