timabell / ef-enum-to-lookup

Generates lookup tables from enum references in Microsoft Entity Framework 6.1
https://www.nuget.org/packages/ef-enum-to-lookup
69 stars 29 forks source link

Breaks on Azure SQL Db "sys.sp_addextendedproperty" #28

Open 12c4IT opened 9 years ago

12c4IT commented 9 years ago

Hi Tim,

If you try and use it when deploying to Azure you will get the error "Could not find stored procedure 'sys.sp_addextendedproperty'. " (Azure SQL does not support this).

It looks as though you are only using this proc to add the "Automatically generated..." description. Could we add this as an option? So we can turn it off if deploying to Azure?

I downloaded code and removed the lines that add the description and tested deploying to Azure and works.

https://github.com/timabell/ef-enum-to-lookup/blob/master/EfEnumToLookup/LookupGenerator/SqlServerHandler.cs#L64-L65

Thanks.

timabell commented 9 years ago

Well that's rather annoying! shame on microsoft for not supporting documentation any more.

It might be better if the generated sql were to detect that it's running on sql rather than require the dev to know about this quirk. I'll take a look when I get a moment. If you'd like to do a pull request let me know and I'll hold off so we don't duplicate the effort.

Thanks for reporting this.

12c4IT commented 9 years ago

I'm happy to look at it. Just not sure what the best approach would be?

Possibly using DbContext to open a connection and determine the version inside your GetDbHandler method? Not sure how this would affect MariaDB etc for your future enhancements?

timabell commented 9 years ago

I'd want to do it in pure SQL because the library now supports generating a migration sql script for a DBA to run.

Note to self: http://stackoverflow.com/questions/1375934/how-can-i-detect-which-version-of-sql-eg-sql-2008-or-sql-azure

timabell commented 9 years ago

I seem to be rather short on time at the moment.

timabell commented 9 years ago

http://stackoverflow.com/q/12458292/10245 - how to document schema for azure (you don't, ffs microsoft) so we're down to detecting if that proc exists and only using it if it does.

Ask the internet: http://dba.stackexchange.com/q/98867/33693