-
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 function to Init Migration #13952
Comments
@bricelam to respond. |
@terrainkognito2017 It doesn't sound like you're getting much value from using Migrations at this stage of development. Have you considered using using code like this instead? (Use Drop-Database to have the schema recreated when your model changes.) context.Database.EnsureCreated();
context.Database.ExecuteSqlCommand("CREATE FUNCTION..."); If you really want to use migrations, you could start with an empty migration. Comment out any DbSet properties and the OnModelCreating method, add the initial migration. Add your functions to that migration. Finally, uncomment your DbSets and OnModelCreating. This lets you easily replace your second migration (using Remove-Migration, Add-Migration) while keeping the function code around. |
Issue #3053 is also about creating a better schema management workflow for the early stages of a project. |
My task is to make the functions be added to the initial migration file Init.cs when calling the Add-Migration Init |
And how can I use the functions I created from the context, besides using https://docs.microsoft.com/ru-ru/ef/ef6/querying/raw-sql |
@terrainkognito2017 As far as we understand your question, there isn't a way to do exactly what you are trying to do, and it's not something we are planning to implement. Given this, @bricelam Is suggesting some other ideas that might solve your originally stated problem in a different way. |
Hello, I want to create an initializing migration to which functions have already been added. It’s inconvenient to manually add to the migration file because during the development phase it is often necessary to initialize the database again and again. To keep for the sake of this a migration file that also changes very often does not make sense. Tell me what solutions there are to insert the sql code (in particular, the function creation code) into the generated migration file.
The text was updated successfully, but these errors were encountered: