Add ExcludeFromMigrations option
See original GitHub issueFeature 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:
- Created 2 months ago
- Comments:9 (5 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
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.
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.