Code Monkey home page Code Monkey logo

Comments (5)

kgrzybek avatar kgrzybek commented on May 10, 2024 1

Thank your for that great question @kacey90

In my opinion the best way to manage database changes is using both approaches - versioning state and versioning transitions. I wrote about this 2 articles on my blog:

http://www.kamilgrzybek.com/database/database-change-management/

http://www.kamilgrzybek.com/database/using-database-project-and-dbup-for-database-management/

As you can read from second linked post I use DbUp library and raw migration scripts to create transitions. I don't use EF migrations because I want to have full control on what is applied to my database. I have not added DbUp to this repository yet because it was first release but I definitely have plan to do that :)

from modular-monolith-with-ddd.

kacey90 avatar kacey90 commented on May 10, 2024

@kgrzybek Thank you for your response. I'll read the articles and try to apply them myself. Many thanks again.

from modular-monolith-with-ddd.

kacey90 avatar kacey90 commented on May 10, 2024

Sorry that I have to reopen this. I'm trying to use DbUp to handle migrations on the project. But I'm unable to use Migrations to generate the script using "Script-Migration" on Visual Studio or dotnet ef "dotnet ef migrations script" on CLI.
When I tried running the command on the UserAccess.Infrastructure module, It throws the following error;

Unable to create an object of type 'UserAccessContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

I included the -verbose parameter in the command for more details and got this;

System.MissingMethodException: No parameterless constructor defined for type 'IGRMgr.Modules.UserAccess.Infrastructure.UserAccessContext'.

The DbContext seems pretty fine to me. Why wouldn't it work?

from modular-monolith-with-ddd.

kgrzybek avatar kgrzybek commented on May 10, 2024

In my implementation UserAccessContext does not have parameterless constructor, only this:

public UserAccessContext(DbContextOptions options, ILoggerFactory loggerFactory) : base(options)
{
    _loggerFactory = loggerFactory;
}

So what I understand from the error message, you need to add parameterless constructor to support EF Migrations.

from modular-monolith-with-ddd.

kacey90 avatar kacey90 commented on May 10, 2024

Yes I noticed. And I tried the parameterless constructor but EF couldn't find the dbContextOptions as a result and threw the following error

No database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions object in its constructor and passes it to the base constructor for DbContext.

from modular-monolith-with-ddd.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.