question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ExcludeFromMigrations option

See original GitHub issue

Feature Request:

Enable use of “ExcludeFromMigrations()”.

A sample of the output code is shown below. For full support, I think it would need to be in the GUI as a checkbox on the Advanced options.

Code

The output would look like this:

modelBuilder.Entity<MyTable>(entity =>
        {
            ...
            entity.ToTable("MyTable", e => e.ExcludeFromMigrations());
            ...
         }

Background

In my client’s environment only allows migrations in the dev environment. When EFCore projects are migrated to other platforms where migrations are not allowed, we’re seeing errors where the [dbo].[__ConversionHistory] does not exist. The “ExcludeFromMigrations()” helps eliminate the error, while allowing test scenarios to create a DB as needed. E.G.: SQLite In-memory db.

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ErikEJcommented, Jul 18, 2023

Got it, but mixing migrations and db first is very uncommon, and you are the first and only person asking for this. And there is a simple way to do this in your own code.

0reactions
visionarycodercommented, Jul 20, 2023

I know you can’t fix process issues with technology. This is a long-running task of mine.

I need to better understand your code. It’s more a question of time for me. If I can figure it out, I can add a PR then we’d both be happy.

As for a single use-case, I don’t fully agree. I have worked with several clients/employers that are very permissive in the dev environment and very restrictive in the production environment. I can’t be the only one to have seen this scenario in the real world. I might be the first to raise it with you but… shrug.

Thanks for answering my questions. As I said, I need to learn more about your code to be more articulate and/or create a PR for your review. Thanks again.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to exclude one table from automatic code first ...
This is now possible in EF Core 5.0 using the ExcludeFromMigrations() method, but strangely enough you have to call the ToTable() method and ......
Read more >
Migrations Overview - EF Core
When a data model change is introduced, the developer uses EF Core tools to add a corresponding migration describing the updates necessary to ......
Read more >
Ability to exclude/skip/ignore parts of the model from ...
I solved it checking from where the entity builder is called, (from "add-migration Xyz" command or the normal dbContext operations) If a ...
Read more >
EF Core migrations
Let's say we need to add a new property called 'CreatedTime' into the 'User' model, the following command can be executed. dotnet ef...
Read more >
【Entity Framework Core】Raw SQL Queries 2
To exclude generating the table, I add "ExcludeFromMigrations" in "OnModelCreating". BookshelfContext.cs ... public class BookshelfContext: ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found