Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Snowflake support #2716

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/Core/RevEng.Core.80/ConnectionStringResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
using Microsoft.Data.SqlClient;
using Microsoft.Data.Sqlite;
using Npgsql;

using Oracle.ManagedDataAccess.Client;
#if !CORE90
using FirebirdSql.Data.FirebirdClient;
using MySqlConnector;
using Oracle.ManagedDataAccess.Client;
#endif

namespace RevEng.Core
Expand Down Expand Up @@ -67,21 +66,20 @@ public IList<string> ResolveAlias()
// Ignore
}

#if !CORE90
try
{
var a = new MySqlConnectionStringBuilder(connectionString);
aliases.Add("mysql");
var a = new OracleConnectionStringBuilder(connectionString);
aliases.Add("oracle");
}
catch
{
// Ignore
}

#if !CORE90
try
{
var a = new OracleConnectionStringBuilder(connectionString);
aliases.Add("oracle");
var a = new MySqlConnectionStringBuilder(connectionString);
aliases.Add("mysql");
}
catch
{
Expand All @@ -98,7 +96,6 @@ public IList<string> ResolveAlias()
// Ignore
}
#endif

return aliases;
}

Expand Down
1 change: 0 additions & 1 deletion src/Core/RevEng.Core.80/DataverseModelFactoryExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore.Scaffolding.Metadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Microsoft.Data.SqlClient;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Metadata;
Expand All @@ -19,10 +18,6 @@
using Microsoft.EntityFrameworkCore.SqlServer.Metadata.Internal;
using Microsoft.EntityFrameworkCore.Storage;
using Microsoft.Extensions.Logging;
using Microsoft.PowerPlatform.Dataverse.Client;
using Microsoft.Xrm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Metadata;
using Microsoft.Xrm.Sdk.Metadata.Query;
using RevEng.Common;
using RevEng.Core;

Expand Down
1 change: 1 addition & 0 deletions src/Core/RevEng.Core.80/RevEng.Core.80.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<ItemGroup>
<PackageReference Include="Bricelam.EntityFrameworkCore.Pluralizer" Version="1.0.0" />
<PackageReference Include="EFCore.Snowflake" Version="8.0.8" />
<PackageReference Include="EntityFrameworkCore.Scaffolding.Handlebars" Version="8.0.0" />
<PackageReference Include="EntityFrameworkCore.Sqlite.NodaTime" Version="8.0.1" />
<PackageReference Include="FirebirdSql.EntityFrameworkCore.Firebird" Version="11.0.0" />
Expand Down
6 changes: 6 additions & 0 deletions src/Core/RevEng.Core.80/ServiceProviderBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
#if !CORE90
using EFCore.Snowflake.Design.Internal;
using FirebirdSql.EntityFrameworkCore.Firebird.Design.Internal;
#endif
using EntityFrameworkCore.Scaffolding.Handlebars;
Expand Down Expand Up @@ -131,6 +132,11 @@ public static IServiceCollection AddEfpt(this IServiceCollection serviceCollecti
var firebirdProvider = new FbDesignTimeServices();
firebirdProvider.ConfigureDesignTimeServices(serviceCollection);
break;

case DatabaseType.Snowflake:
var snowflakeProvider = new SnowflakeDesignTimeServices();
snowflakeProvider.ConfigureDesignTimeServices(serviceCollection);
break;
#endif
case DatabaseType.SQLite:
var sqliteProvider = new SqliteDesignTimeServices();
Expand Down
1 change: 1 addition & 0 deletions src/Core/RevEng.Core.90/RevEng.Core.90.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

<ItemGroup>
<PackageReference Include="Bricelam.EntityFrameworkCore.Pluralizer" Version="1.0.0" />
<!--<PackageReference Include="EFCore.Snowflake" Version="8.0.8" />-->
<PackageReference Include="EntityFrameworkCore.Scaffolding.Handlebars" Version="9.0.0-beta1" />
<PackageReference Include="EntityFrameworkCore.Sqlite.NodaTime" Version="9.1.0" />
<!-- <PackageReference Include="FirebirdSql.EntityFrameworkCore.Firebird" Version="11.0.0" />-->
Expand Down
2 changes: 1 addition & 1 deletion src/Core/efcpt.8/Options/ScaffoldOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal sealed class ScaffoldOptions
[Value(
1,
MetaName = "provider",
HelpText = "Name of EF Core provider, or use an abbreviation (mssql, postgres, sqlite, oracle, mysql, firebird). May not be required, as an attempt is made to resolve the provider from the connection string.")]
HelpText = "Name of EF Core provider, or use an abbreviation (mssql, postgres, sqlite, oracle, mysql, firebird, snowflake). May not be required, as an attempt is made to resolve the provider from the connection string.")]
public string Provider { get; set; }

[Option('o', "output", HelpText = "Root output folder, defaults to current directory")]
Expand Down
1 change: 1 addition & 0 deletions src/GUI/EFCorePowerTools/Dialogs/ConnectionDialog.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
SelectedValue="{Binding DbType, Mode=TwoWay}"
SelectedValuePath="Tag" Grid.Row="3" Margin="12,2" Width="136" HorizontalAlignment="Left" >
<ComboBoxItem Tag="6" >MySQL</ComboBoxItem>
<ComboBoxItem Tag="11" >Snowflake</ComboBoxItem>
</ComboBox>

</Grid>
Expand Down
13 changes: 4 additions & 9 deletions src/GUI/EFCorePowerTools/Dialogs/ConnectionDialog.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,13 @@ private void CmdDatabaseType_SelectionChanged(object sender, System.Windows.Cont

switch (dbType)
{
case DatabaseType.Undefined:
case DatabaseType.SQLite:
case DatabaseType.Npgsql:
case DatabaseType.Oracle:
case DatabaseType.SQLServerDacpac:
case DatabaseType.Firebird:
case DatabaseType.SQLServer:
break;

case DatabaseType.Mysql:
txtSample.Text = "Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;";
break;
case DatabaseType.Snowflake:
txtSample.Text = "ACCOUNT=<accountid>;DB=MYDATABASE;SCHEMA=MYSCHEMA;USER=MYUSERNAME;PASSWORD=myPassword";
break;

default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions src/GUI/RevEng.Shared/DatabaseType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ public enum DatabaseType
Oracle = 7,
SQLServerDacpac = 8,
Firebird = 10,
Snowflake = 11,
}
}
29 changes: 29 additions & 0 deletions src/GUI/RevEng.Shared/Providers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public static DatabaseType ToDatabaseType(this string providerAlias, bool isDacp
case "FirebirdSql.EntityFrameworkCore.Firebird":
return DatabaseType.Firebird;

case "EFCore.Snowflake":
return DatabaseType.Snowflake;

default:
return DatabaseType.Undefined;
}
Expand Down Expand Up @@ -443,6 +446,28 @@ public static List<NuGetPackage> GetNeededPackages(DatabaseType databaseType, bo
});
}

if (databaseType == DatabaseType.Snowflake)
{
var pkgVersion = string.Empty;
switch (codeGenerationMode)
{
case CodeGenerationMode.EFCore8:
pkgVersion = "8.0.8";
break;

default: throw new NotImplementedException();
}

packages.Add(new NuGetPackage
{
PackageId = "EFCore.Snowflake",
Version = pkgVersion,
DatabaseTypes = new List<DatabaseType> { databaseType },
IsMainProviderPackage = true,
UseMethodName = "Snowflake",
});
}

return packages;
}

Expand Down Expand Up @@ -519,6 +544,10 @@ private static Dictionary<string, List<string>> GetProvidersWithAliases()
"FirebirdSql.EntityFrameworkCore.Firebird",
new List<string> { "firebird" }
},
{
"EFCore.Snowflake",
new List<string> { "snowflake" }
},
};
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/GUI/Shared/Helpers/ReverseEngineerHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,8 @@ private string GetProviderName(DatabaseType databaseType)
return "SqlServer";
case DatabaseType.Firebird:
return "Firebird";
case DatabaseType.Snowflake:
return "Snowflake";
default:
return "[ProviderName]";
}
Expand Down
Binary file modified src/GUI/lib/efreveng80.exe.zip
Binary file not shown.