EnsureCreated throws when database doesn't exist

Viewed 68

Update: Attempting to recreate in a test project failed.
Will try to see what causes the problem by adding parts from original project one-by-one.

I don't have a lot of experience with entity framework, but as far as I underantand, the EnsureCreated() method should create the database if it doesn't already exist - as per documentation:

If the database does not exist, then the database is created and the Entity Framework model is used to create the database schema.

However, this simple code throws a Microsoft.Data.SqlClient.SqlException:

dbContext.Database.EnsureCreated();

A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.)

When I manually create an empty database before running this code, I get the desired result - the code runs and creates the relevant database tables.

What am I missing here?

0 Answers
Related