.net - 'CREATE FUNCTION' must be the first statement in a query batch. Entity Framework Code Frist -
i have inline sql scripts (functions , stored procedures) generated entity framework , code first approach.
update-database -script -sourcemigration:0
with above command sql script file execute on test or production.
however cannot run generated script because of next error:
'create function' must first statement in query batch.
the script generated as:
if @currentmigration < '201410150019333_createfngeneraterequestcode' begin create function [dbo].[fngeneraterequestcode] ( @userid varchar(max) ) returns varchar(14)
how can prepare ?
you have generate code , execute dynamic sql.
declare @sql nvarchar(max) set @sql = ' if object_id(''fn_test'') not null drop function fn_test go create function fn_test(@a int) returns int begin homecoming @a end ' if 1 = 1 begin exec(@sql) end
.net entity-framework sql-server-2008 ef-code-first code-first-migrations
No comments:
Post a Comment