KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm creating SQL procedures in Entity Framework by using Sql methods in the migration. For example in an Up() I'm doing Sql(@"SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE FUNCTION dbo.MyFunction ... GO"); Now my problem is with the GO s: if I want to be able to script my migrations (for using on a live server) I need the GO s in the generated script, otherwise it doesn't work. However for running Update-Database without the -script option (for use while developing), it gets upset about the GO s. I've found some partial answers: How to add code to initialize sql database The answer by Bart provides a method to call to divide the statement up into multiple Sql calls. The problem with this is that it affects the generated script when running with the -script option, so back to square 1. How can I override SQL scripts generated by MigratorScriptingDecorator Also looks like it could be useful. My question is therefore: is there either a way to know whether you're running the migration with the -script option, or a better way to script my SQL procedures in the migrations?
Tags (comma-separated)
Save Edits
Cancel