elsa-workflows / elsa-workflows/elsa-core

SQL Server Entity Framework Core Migration with Custom DbContext

Open
#7,025 3 comments 0 reactions 0 assignees View on GitHub
triaged
Dominant language
C#
Stars
7.9k
Forks
1.5k
Avg merge
15h 22m
Merged PRs (30d)
114

Description

## Description
Unable to run the SQL Server Entity Framework Core Migration with Custom DbContext

## Steps to Reproduce
To help us identify the issue more quickly, please follow these guidelines:

1. **Detailed Steps**:

1. I am using .NET 9.
2. I have a class library project where I am maintaining the code-first approach to create the custom DB entities.
3. It can update my database with the custom DB entity table.
4. When I am trying to use the latest Elsa version and inheriting my DbContext class with the ElsaContext its showing an error when I am trying to create new migration with Elsa tables.

2. **Code Snippets**:

```
using Elsa.Persistence.EntityFrameworkCore.DbContexts;

using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;

using NodaTime;

using SB.DB.Entities.Models;

using ServiceProvider = SB.DB.Entities.Models.ServiceProvider;

namespace SB.DB.Entities;

public class SbDbContext : ElsaContext
{
public SbDbContext(DbContextOptions options)
: base(options)
{
}

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
```
3. **Directory.Packages.props**
```


true
true


3.4.2















































```

4. **Package Manager Command**:

`PM> add-migration ElsaCombined`

6. **Error I am getting as below**

Unable to create a 'DbContext' of type 'SbDbContext'. The exception 'Could not load type 'Microsoft.EntityFrameworkCore.MutableAnnotatableExtensions' from assembly 'Microsoft.EntityFrameworkCore, Version=9.0.10.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.