Question: I want to set default value to `Id` column in `Person` table with a function
that goes like this:

Function:

```
IF OBJECT_ID ( 'GetLastId','FN') IS NOT NULL   
    DROP function GetLastId;  
GO  

CREATE FUNCTION [dbo].[GetLastId]
    (@TableName nvarchar(max)) 
RETURNS int
AS
BEGIN
    DECLARE @LastId int;
    DECLARE @sql nvarchar(max);

    SET @sql = 'SELECT @LastId = ISNULL(MAX(Id), 0) + 1 FROM ' + @TableName + ';'

    EXECUTE sp_executesql @sql, N'@LastId int output', @LastId = @LastId output;

    RETURN @LastId
END

```

and then:

```
UPDATE Person 
SET Id = dbo.GetLastId('Person')

```

Running this code throws an error:

> 
> Only functions and some extended stored procedures can be executed from within a function.
> 
> 
> 

So how to fix this and make it work as a default value?

And please do not say "Use triggers..." as I intend to use it with Entity Framework Core as default value for primary keys.

Thanks

Answer: 
I had the same problem and I'm guessing it has to do with gevent, which was the case for me. To solve it I did "pip install gevent==1.5a3"

If this doesn't fix it then I would try to troubleshoot which individual library is causing this issue then install a different release version using the library name then ==library update
Try the following clean installation with dependancies as well.

```
pip install -I eel --force-reinstall --no-cache-dir

```