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

Running fluentmigrator from linux, is mono still required? .net core? #1383

Open
kevinlong206 opened this issue Nov 20, 2020 · 19 comments
Open

Comments

@kevinlong206
Copy link

kevinlong206 commented Nov 20, 2020

Describe the question
Is using 'mono' still the only way to get fluentmigrator running in Linux? I have a use case where I need to run it in a linux container from a ci/cd pipeline. I see mention of supporting .net core in past github issues, can the project be built and run using .net core without mono now?

These steps in a Dockerfile seem to work to get the Migrate.exe to run, I'm just wondering if there is a better way to do this.

RUN echo "deb https://download.mono-project.com/repo/ubuntu stable-xenial main" > /etc/apt/sources.list.d/mono-official.list \
  && apt-get update \
  && apt-get install -y mono-runtime binutils curl mono-devel nuget unzip \
  && rm -rf /var/lib/apt/lists/* /tmp/*

RUN mkdir /tmp/FluentMigrator.Tools \
 && nuget install FluentMigrator.Tools -Version 3.2.9 -OutputDirectory /tmp/FluentMigrator.Tools/ \
 && mv /tmp/FluentMigrator.Tools/FluentMigrator.Tools.3.2.9/tools /usr/local/bin/FluentMigrator.Tools \
 && rm -rf /tmp/FluentMigrator.Tools`

Documentation Pages You've Read So Far
https://fluentmigrator.github.io/articles/guides/contribution.html#linux-macos
#712
#1039

Expected benefit
The ci/cd system I must use supports only linux containers for build/deploy operations, I am looking for the most optimal way to build and run fluentmigrator in this context.

Information (please complete the following information):

  • Database target is Azure SQL
  • Linux containers to be based on ubuntu

Additional context
n/a

Thanks!

@jzabroski
Copy link
Collaborator

I think the limitations are with the driver programs. We had started to look into using TestEnvironment.Docker to verify end to end integration tests. Fabien Menager has made some PRs to that repo and the main issues were around culture issues related to Oracle needing time zone I think.

@kevinlong206
Copy link
Author

@jzabroski thanks for the reply - I'm still unclear though. My goal is to run fluentmigrator on ubuntu container, and run migrations against azure SQL. Is mono the best way, or can I use .net core without mono? For context I am a linux guy with basically zero .NET experience, trying to do some devops stuff for a windows dev team.

@fubar-coder
Copy link
Member

FluentMigrator.Tools is a somewhat special case, as it contains drivers and native DLLs that are meant to be used from Windows and mono was the best way to execute those assemblies. It might be possible that the FM.Tools tool is executable with .NET 5.0, but I haven't tested it yet. However, when you write your own migration tool, you can definitely use it from .NET Core (running on Linux) to migrate SQL Server databases.

@kevinlong206
Copy link
Author

@fubar-coder the team I am working with just runs Migrate.exe . It looks like I can run Migrate.exe via mono, and if that is the solution then it's fine. I just don't know if there is a better way. We didnt have plans to write a new migration tool, just to run the existing tool from linux.

@jzabroski
Copy link
Collaborator

jzabroski commented Nov 20, 2020

@kevinlong206 Thanks for the additional context.

Mark and I discussed and we think, depending on your database driver, FluentMigrator.DotNet.Cli might be a better approach than the exe. It uses a special type of Nuget package called a Tool that can be installed globally or locally.

I recommend installing it locally via creating a Tool Manifest. The nice thing about this is it becomes easier to integrate into the overall Visual Studio environment since tool manifest.json gets checked into source control under a top level .tools folder.

The unknown is whether the specific db driver you need supports Linux. I think MySql, SQL Server and the Managed Oracle drivers should work but I haven't tried them and am going off memory.

Let me know if you have any questions to go with this approach. I used Migrate.exe for the longest time but as of last December all my projects use FluentMigrator.DotNet.Cli.

The one gotcha with using FluentMigrator.DotNet.Cli is that since it has it's own deps.json (list of dependencies dotnet.exe loads on top of FluentMigrator.DotNet.dll entry point), your team just needs to make sure the version of FluentMigrator.DotNet.Cli matches the nuget version of FluentMigrator nuget package they write migration against, otherwise there will be load and link errors.

@jzabroski
Copy link
Collaborator

@kevinlong206 Just wondering if you were able to have any success with the above guidance?

@kevinlong206
Copy link
Author

@jzabroski thanks again for the info. I have not had a chance to test this yet but plan to in the next few weeks. I won't be offended if you close the issue and appreciate the guidance.

@jzabroski
Copy link
Collaborator

@kevinlong206 I think of it as teamwork, since that was open source is. So the guidance is in part in hopes you can tell us what works for you (or if it didn't work). I think there is a decent chance it should work, but there is a decent chance you might get a runtime exception that can be quickly fixed.

Happy holidays! I am a big fan of Thanksgiving because, in the spirit of saying thanks to all who I am thankful for, I get to say, Thank you, @kevinlong206 !

@lillo42
Copy link
Contributor

lillo42 commented Jan 14, 2021

At home I used Linux Ubuntu 20.04 and I don't have a problem to run FluentMigrator in linux, but to run FluentMigrator I had develop my own tool(where a can just run without any parameters and this tool have a reference to my projects who have my migrations) and it`s run wells.

I will take a look if dotnet tools work fine in linux

@jzabroski
Copy link
Collaborator

@lillo42 Thanks for all your help. You really stepped up the past few months. Curious what you found?

@lillo42
Copy link
Contributor

lillo42 commented Feb 3, 2021

@jzabroski
To run dotnet tool isn't necessary, but to build/run test is necessary install Mono, if we want we could add Microsoft.NETFramework.ReferenceAssemblies to project and that allow us to build in Linux/MacOSX without install Mono, but if we want to run test still necessary install Mono.

Fun fact, I've tried to use in .NET 5 project with FM tools and I got some problem relate with System.Runtime, so for migrations is recommend use .NET Standard 2.0.

Follow attached a project with some migrations in .NET Standard 2.0 running the migrations on Docker
FluentMigratorDocker.zip

@lillo42
Copy link
Contributor

lillo42 commented Feb 10, 2021

To allow FM build/test using only .NET Core on Linux is necessary add support/update Db2 package SAP Hana package (https://developers.sap.com/tutorials/hana-clients-dot-net-core.html) also SAP Anywhere doesn't have support for .NET Core

@jzabroski
Copy link
Collaborator

also SAP Anywhere doesn't have support for .NET Core
-- @lillo42

We need to drop SAP Anywhere. See: #1218
I think the number of users of SAP Anywhere FluentMigrator is extremely low, possibly single digits. @eloekset added the support for a past emloyer but other than that, we dont know anyone whose used it and never got a support ticket for it.

@fubar-coder
Copy link
Member

@jzabroski Maybe we should think about dropping JET support too.

@jzabroski
Copy link
Collaborator

@jzabroski Maybe we should think about dropping JET support too.

JET

  • Doesn't support Linux (at least not for free, anyway)
  • Requires System.Data.Odbc to work on .NET Core

So... it may be time to drop it. I think people prefer Sqlite anyway, since its open source and the maintainer is very open to companies like expensify sponsoring its development.

@lillo42
Copy link
Contributor

lillo42 commented Feb 11, 2021

I think it's better we work on this issue on next FM major.
Next major where we are going to drop support for JET, SAP Anywhere and SQL CE, right?
Maybe we can do some experiment to see if is necessary change more anything.

So... it may be time to drop it. I think people prefer Sqlite anyway

I've never ever listen about JET, here was the first time 😄

@jzabroski
Copy link
Collaborator

Fun fact, I've tried to use in .NET 5 project with FM tools and I got some problem relate with System.Runtime, so for migrations is recommend use .NET Standard 2.0.

@lillo42 The fix for this issue will go out today in v3.2.15

@CraigComeOnThisNameCantBeTaken

Fun fact, I've tried to use in .NET 5 project with FM tools and I got some problem relate with System.Runtime, so for migrations is recommend use .NET Standard 2.0.

@lillo42 The fix for this issue will go out today in v3.2.15

Still doesnt work. Doesnt even work for .NET Standard 2.1 let alone .NET 5 using v3.2.17.

Should this be written down somewhere?

@jzabroski
Copy link
Collaborator

@CraigComeOnThisNameCantBeTaken Can you elaborate what issue you are running into? My response in your issue #1491 I think covers the solution you are looking for. Please try it and report back in that thread what you find. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants