-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add/Rename/Delete/Data Type Changes of Column Should Auto Be Modified In Database Table By EF Core #30690
Comments
@hintsofttech you seem to be proposing changes to EF Core's Migrations feature, but I'm not clear on exactly what you're asking. Can you please elaborate each point and provide examples? |
Yes, We mean EF Core's Migration feature but without actually any manual migration... it should auto make changes accordingly without even the need of migration... |
Sounds like you're asking for automatic migrations, see #6214; read through that issue to understand why we've decided not to implement that. |
But none is satisfied by avoiding automigration. This should be available optionally. If needed, developer should enable it. |
Duplicate of #6214 |
@hintsofttech the EF recommendation is either to use Migrations, or to use EnsureCreated/EnsureDeleted in testing and in various early stage development scenarios. We do think we can improve on the early prototyping phase, but we don't intend to do that via automatic migrations. |
But please try to understand the following cases where there must be automigration should exists:-
|
I don't understand - if there's no connection to any database, what is it that you're expecting EF to do?
I don't really understand what this means. In general, it's very hard to understand exactly what it is that you're asking for. Showing some precise code with exactly what you want would be helpful. |
Why r you all not understanding ? Clients just download our installation setup file and install. In that case if we change our model, our clients, after every update, suffer errors untill we manually change the design of the table to match with our c# model. They just make payment online and use our app. We don't want them to contact us for every updates. Actually we want our updates with automatic treatments for any changes. if automigration works, these problems will automatically be solved. |
@hintsofttech Have you looked at migration bundles? |
sir, we never add migration. still we believe why should we bother for extra more steps after all we are programmer and we make things simplest but we are making it complicated ??? auto-migration is the need for most of the erp-programmers. please consider... |
If you use Database First, put your database schema in a .dacpac and run dacpac publish as part of your setup. |
And what about changes made after installation How will be following be updated automatically ?
|
@hintsofttech as I wrote above, read #6214 for reasons why automatic migrations weren't a good idea, and didn't work well in EF6. Interestingly, when users ask for automatic migrations, they frequently do so for the early prototype, whereas you want them to be used in production scenarios. What's your exact reason for not wanting to use regular Migrations? After all, it only requires you to perform a minimal gesture to generate the migration ( |
Sir, as you know migrations requires a lot of attentions for what have been changed which we don't want to track it for even simple-simple changes. dbcontext.database.migrate() method through which we could do it wheneven client update our app and all the changes made takes effect for that client. |
This exact API already exists, see these docs. It allows you to apply any new migrations automatically when your application starts up. |
sir, we tried dbcontext.database.migrate() method for followings:-
nothing changed to existing database... |
@hintsofttech did you generate a migration first, e.g. by running The flow is that as the application writer, you generate a migration after making a code change. For example, after changing the name of a property, you run |
sir when I call dotnet ef migrations add from cli |
@hintsofttech you're probably executing the command in the wrong directory; you need to do this in the directory of your C# project which reference EF Core and has your DbContext definition. I suggest giving our Migration introductory page a good read; this should make you familiar with the basics. |
thankx a lot sir, it's working as desired except
|
Glad to hear it's work for you. Changing column order after table creation simply isn't supported by the majority of databases (IIRC only MySQL supports that). Re triggers/procedures/functions/views: these are database objects which aren't modeled in your EF model. In other words, EF can derive a table definition from your .NET types (.NET properties -> database table columns), but e.g. a view is just an arbitrary SQL query which you need to specify yourself. So you'll need to manage these yourself, but Migrations allow you to easily integrate raw SQL into your migrations - see these docs. This allows you to e.g. insert a CREATE VIEW into a migration to cause that to be created/altered/dropped. |
sir, but here is problem that suppose thousands of migrations we added sir, ef core is comparing all the migrations one-by-one and changing all of then sequentially. but prior is better approach because client side migration table data maybe missing anytime.... which make sense for real changes to be migrated. |
This not something you should be doing. We do have #2174 tracking the ability to squash migrations, for when too many migrations start to become a performance issue. But this typically happens only in very extreme cases, or when migrations are misused (e.g. with data seeding of huge data). In almost all regular scenarios, migrations scale well. In other words, I advise you to consider why you're thinking about deleting your migration folder.
That is not what EF does. It checks the migrations history table in the database to see which migrations have been applied, and applies the missing ones.
There are various reasons why this does not work as a scalable approach. As I advised several times before, read #6214 thoroughly to understand why we don't intend to implement automatic migrations. Note that we've had this same conversation before several times already, in #27160 and in #27195. |
Duplicate of #27160 |
sir, we agree with 👍 complete understanding is very clearly provided by rhyous sir the same thing we are also trying to make clear that we humbly request you all try to listen us think once again |
@hintsofttech I posted a long comment explaining all this in #6214 (comment). I'll go ahead and close this issue as no new information has been raised compared to the older issues discussion this. |
Error After Add/Rename/Data Type Changes of Column
The text was updated successfully, but these errors were encountered: