efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Is the MigrationsAssembly() statement required when using a separate migration project if you aren't migrating in your app

Open jasekiw opened this issue 2 years ago • 3 comments

I was looking through the documentation for moving migrations to another project so that I can build my project without the migrations and speed up my builds when I don't need to run migrations.

However the documentation instructs you to add the migration project as a dependency and reference it when constructing your dbcontext with x.MigrationsAssembly("WebApplication1.Migrations").

My question is:

Is it really required to add x.MigrationsAssembly("WebApplication1.Migrations") if I'm not going to run the migrations in my app? From what I can tell the queries seem to run fine without this but I don't want to assume anything.

My plan is to build a separate project that I can run my migrations from so I only need to build the migrations when I go to use them.

Documentation Link

It seems others have been successful at doing this: https://github.com/dotnet/efcore/issues/2174#issuecomment-1483833787

jasekiw avatar Mar 16 '23 17:03 jasekiw

Note from triage: putting on the backlog to see if we can make this better.

ajcvickers avatar Mar 18 '23 10:03 ajcvickers

@MikaelEliasson Regarding your comment: https://github.com/dotnet/efcore/issues/2174#issuecomment-1483833787 I'm curious how your approach has held up over time? Have you ran into any issues or has it been smooth sailing?

jasekiw avatar Feb 12 '24 12:02 jasekiw

Only smooth sailing so far except some Devs not unloading that project and still wasting time.

We also generate and apply migrations through yarn commands so we almost never need to load the project.

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Jason Gallavin @.> Sent: Monday, February 12, 2024 12:23:26 PM To: dotnet/efcore @.> Cc: Mikael Eliasson @.>; Mention @.> Subject: Re: [dotnet/efcore] Is MigrationsAssembly when using a seperate migration project if you aren't migrating in your app (Issue #30510)

@MikaelEliassonhttps://github.com/MikaelEliasson Regarding your comment: #2174 (comment)https://github.com/dotnet/efcore/issues/2174#issuecomment-1483833787 I'm curious how your approach has held up over time? Have you ran into any issues or has it been smooth sailing?

— Reply to this email directly, view it on GitHubhttps://github.com/dotnet/efcore/issues/30510#issuecomment-1938580141, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAGY32EDLH4JT2F3766YUDLYTICT5AVCNFSM6AAAAAAV5RUGG2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZYGU4DAMJUGE. You are receiving this because you were mentioned.Message ID: @.***>

MikaelEliasson avatar Feb 13 '24 10:02 MikaelEliasson