I've started building a project using code-first in EF4.0 to build my database. I now wish to create some stored procedures in SQL Server 2008 that will work on the created data tables.
However, since CF drops and recreates the entire database, I would lose any stored procedures I create and would have to rebuild them each time - it would be easy to inadvertently lose work this way.
Are there "best practices" here? Of course I could always lock down the schema now and forget about code first but it's not ideal. Why would EF delete the entire DB - is there a way to delete just the tables?
You can use custom database initializer which will create your stored procedures every time you recreate database. You can also use EF migrations to build your database incrementally instead of deleting it after each change. Up method in the migration can use Sql method to create stored procedures.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With