fluentmigrator | Fluent migrations framework for .NET | Database library
kandi X-RAY | fluentmigrator Summary
kandi X-RAY | fluentmigrator Summary
Fluent Migrator is a migration framework for .NET much like Ruby on Rails Migrations. Migrations are a structured way to alter your database schema and are an alternative to creating lots of sql scripts that have to be run manually by every developer involved. Migrations solve the problem of evolving a database schema for multiple databases (for example, the developer's local database, the test database and the production database). Database schema changes are described in classes written in C# that can be checked into a version control system.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of fluentmigrator
fluentmigrator Key Features
fluentmigrator Examples and Code Snippets
Community Discussions
Trending Discussions on fluentmigrator
QUESTION
I use Fluentmigrator in my Visual Studio project to version and migrate a single MS SQL Server database.
Within that db, there are multiple customer dedicated database schemas, and wish to migrate them independently from each other, hence each schema would have a dedicated VersionInfo table.
I see this might be possible with this, by overriding the meta data: https://fluentmigrator.github.io/articles/version-table-metadata.html
The next step would be to execute sql scripts against the target schema using
...ANSWER
Answered 2022-Jan-21 at 09:32Glad its open source, found it in the code. EmbeddedScript function has a 2nd optional parameter which is a dictionary, where you can list tokens to be replaced in your to be executed sql code.
This is where it got implemented, but since then it got improved https://github.com/fluentmigrator/fluentmigrator/issues/625 and now the token key has to be in $(mytokentoreplace) in the sql script, and just "mytokentoreplace" in your c# dictionary which you pass to Embeddedscript to replace the tokens to whatever you want.
You can pass in your dictionary to your migration classes using dependency injection: https://fluentmigrator.github.io/articles/obsolete/app-context.html
then just call Execute.EmbeddedScript("mysqlscript.sql", service.Tokens); to replace the tokens, which in my case is schema.
QUESTION
On my current project (.NET 5, ASP.NET Core), we're using FluentMigrator for running EF Core migrations which works flawlessly. We're in the process of setting up our infrastructure in Azure to communicate via Managed Identities and have set op a system assigned managed identity from our (web) app service to our SQL server.
We followed this guide to the point: https://docs.microsoft.com/en-us/azure/app-service/app-service-web-tutorial-connect-msi?tabs=windowsclient%2Cdotnetcore
However, we get the following null pointer reference from FluentMigrator:
...ANSWER
Answered 2021-Sep-18 at 18:00Nothing wrong with FluentMigrator at all. It was just me having a tunnel-vision and followed Microsofts guide where they have put the SqlAuthenticationProvider.SetProvider(...)
inside of services.AddDbContext(...)
:-) Moving it outside of the AddDbContext(..)
like this made it work:
QUESTION
I have been working on a .Net Core project and I want to use MongoDb as a database implementation. I have created my entities that will be created as Collections. You can see the entities below.
When I start the project and if the database does not exist on the server, database and collections must be created according to entities that I have created. I should not create a database manually.
For Mssql, I am using FluentMigrator for this process. How can I handle it for MongoDb?
...ANSWER
Answered 2021-Sep-12 at 04:14I should not create a database manually
I think we have some miss-understood here, on IMongoClient
interface, it has a method GetDatabase
that will create the database automatically on the server if it doesn't exists yet, so... basically, that kind of migration is automatic.
database and collections must be created according to entities that I have created
IMongoDatabase
interface have GetCollection(Your collection name)
that would generate the collection too as far as I can remember.(My code got fully worked, despite I'm not setting anything on the database).
I think our most realistic case was create the index on the collection if it's doesn't exists yet.
QUESTION
How does FluentMigrator know what migrations to execute / migrate when you start up the application?
Example: I got two migrations already performed (1 and 2). Now I create a third migration and give it an id of 3
. When I launch my application, FluentMigrator will execute the migrations, but how does it know to skip the first two?
ANSWER
Answered 2021-Jun-04 at 12:27A table called VersionInfo is created in the database where information about each migration is recorded. Before applying the migration, a check will be performed to see what records are already in this table.
QUESTION
I have loaded a solution developed in a older visual studio version in my local visual studio 2017. There are many reference to external dlls. When I compile the solution I get error as below despite the fact that the dll's are available under the "packages" folder in the solution. The target framework of the projects in the solution are set to .NET Framework 4. I have .NET Framework 4.7.1 installed in my computer. I would appreciate some help on this.
Updated with project file
...ANSWER
Answered 2021-Mar-02 at 05:38The issue is that the hintpath
of your project did not point to the right dll path of your packages
folder under the solution folder.
If the csproj
exists under the proejct folder while the packages folder is on one above folder of the file, then the error happens.
You should change ..\..\
to ..\
. Use the right path.
Or try this command under Tools-->Nuget Package Manager-->Package Manager Console
QUESTION
I am trying to open a solution using Visual studio 2019 and visual studio 2017. All the projects in the solution are loading except for one. When trying to load the unloaded project i get an error in the output window as
TakstMVC.csproj : error : The imported project "....build\MSBuild.Community.Tasks.targets" was not found. Confirm that the expression in the Import declaration "TakstMVC\.....build\MSBuild.Community.Tasks.targets" is correct, and that the file exists on disk. TakstMVC\FluentMigrator.targets
When i tried to open using VS 2017 i saw a migration report which said
TakstMVC.csproj: The application which this project type is based on was not found. Please try this link for further information: http://go.microsoft.com/fwlink/?LinkID=299083&projecttype=E3E379DF-F4C6-4180-9B81-6769533ABE47
Part of the .csproj of the project is as below:
...ANSWER
Answered 2021-Mar-02 at 05:38The error is clear that you did not import the MSBuild.Community.Tasks.targets
correctly on your local area. The reason is that you did not install MSBuild.Community.Tasks.targets
on your PC or the import path from csproj
file is incorrect.
You should check this document to install the right target.
First, remove xml node under csproj
file like these:
QUESTION
I try to run dotnet tool install
in Azure DevOps and test the tool.
Locally
...ANSWER
Answered 2021-Feb-11 at 13:43To make this work, I think you will need to add an initial UseDotNet
task to setup the .NET SDK. Generally, this is a best practice that makes it clear which version you are expecting and ensures that you're building with that version. That process also ensures that your global tools will work as expected. The code:
QUESTION
When I connected to SQL Server, Fluent Migrator creates a Version Info
table in the master
database, but I create the database myself with a SQL script, then the app drops because it can't find the version info
table.
What do I need to do for my script to run correctly?
C# code:
...ANSWER
Answered 2021-Jan-16 at 05:28You create the database outside of FluentMigrator, then specify the database to use, by providing a connection string parameter Initial Catalog=xxx
or Database=xxx
(they mean the same thing)
Creating the db is done by the same way you'd run any normal SQL, using a SqlCommand, before you run your migrations
QUESTION
I have console app that uses FluentMigrator migrations, but now I need to implement user confirmation before actual migration process. I got into repo sources, found out about version loader and how to get unapplied list of migrations using IServiceProvider
. But can't find a way yet to print SQL script of the migration that will be used in the MigrateUp()
. I am using SQL Server package as well. Could anyone point a direction?
ANSWER
Answered 2020-Dec-04 at 18:09There is IMigrationGenerator
that can be resolved by using IServiceProvider
. But, unfortunately, there are no methods that support IMigrationExpression
parameter (see below), so I had to write either wall of if-else
statements for each type or use a reflection. I used second option. Maybe there is better approach?
QUESTION
I have a multi-tenanted database. The tenant-specific data is stored inside it's own (PostgreSQL) schema.
I'd like to be able to use FluentMigrator to deploy new tenants as required. I've set up an example on GitHub where a HTTP post to an endpoint will deploy a schema. However deploys it to the public schema by default. I'd like to be able to specify the schema to deploy to.
I.e.
...ANSWER
Answered 2020-Aug-29 at 14:49I was struggling with this exact same issue and also the same enviroments. .Net-core, FluentMigrator and Postgre with different schema's. I have been using the Obsolete functions and allready noticed that I had to create my own: ConventionSet. I was able to fix this in the following, where I first must say: Thank you for your git, this helped me to also figure out my problem, here goes:
First thing I did was manually create a database and a schema with a different name then: public. Then I adjusted the startup.cs
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install fluentmigrator
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page