0

I described the database through Fluent Api.

However, I want to use Database.EnsureCreated (); some additional SQL code was executed.

Where can i place it?

6
  • You can place it anywhere that is in-scope of the calling code. Am I understanding your problem correctly? Commented Mar 9, 2020 at 20:32
  • In other words, find a place to put the code, put it in an appropriate namespace, add the necessary using statements, and call it like you would call any other method. Commented Mar 9, 2020 at 20:34
  • @RobertHarvey You understood not quite right. I want that if the database was absent when creating the context, then Database.EnsureCreated (); it was created + executed by some SQL code. Can I override any DbContext method to achieve the goal? Commented Mar 9, 2020 at 20:38
  • Sorry, but I still don't understand what you are asking. If you just want to execute your own SQL though EF core, this explains how to do that. Commented Mar 9, 2020 at 20:41
  • @RobertHarvey Some like stackoverflow.com/questions/21731889/… Commented Mar 9, 2020 at 20:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.