London Dev Meetup Rescheduled! Due to unavoidable reasons, the event has been moved to 21st May. Speakers remain the same—any changes will be communicated. Seats are limited—register here to secure your spot!

InvalidOperationException: Failed to execute script because validation failed: 'Not an EPiServer database'

Vote:
 

Can someone explain in detail why this error happens. I get it occasionally on brand new CMS 12 projects created via CLI or VS22. I see the mdf file in the App_Data folder. Somewhere it's failing to create the db however. I don't see the db in MSSQLLocalDb.

#300325
Edited, Apr 18, 2023 19:01
Vote:
 

Couple of things to make sure - 

  • Check the connection string is pointing to correct database (which it must be in your case).
  • Try login with the same credentials if it let's you login to MSSQL.
  • Make sure CLI commands you are using are updated.

Additionally, When I was trying to set it up on my local I realized the CLI commands were outdated. I had to figure it out with opening a forum discussion and based on responses I received; Finally got it configured. You can go through my blog post if it helps. 
https://world.optimizely.com/blogs/stackmanoz/dates/2022/3/updated-commands-to-install-commerce14-and-cms12/

I believe those are still spot-on in terms of setting up latest version with optimizely CLI. 

Do let me know if it helped.

#300435
Apr 20, 2023 14:21
Vote:
 

Hi Manoj, 

Thanks for the recommendations. Here's what I'm seeing. 

  • Check the connection string is pointing to correct database (which it must be in your case). 

"ConnectionStrings": {
    "EPiServerDB": "Data Source=(LocalDb)\\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\\ExampleProject.mdf;Initial Catalog=ExampleProject;Integrated Security=True;Connect Timeout=30"
  },

  • Try login with the same credentials if it let's you login to MSSQL.

I can login to SSMS and see the db was created, but there are no tables. 

  • Make sure CLI commands you are using are updated.

My versions of optimizely db cli and episerver.templates

  • Optimizely database cli tool, v2.0.0 -    
  • Episerver.Templates v1.6.0

I used this command to create the alloy template

  • dotnet new epi-alloy-mvc

I was under the impression that with the new project templates, the database would be automatically created. It wasn't. So I figured I would try to update the schema and I know the old initialize-epidatabase command no longer works. So i tried dotnet episerver update-database ExampleProject.csproj. I'm getting a SqlException(0x80131904): Cannot attach the file ' C:\users\.dotnet\tools\.store\episerver.net.cli\2.0.0\episerver.net.cli\2.0.0\tools\net6.0\any\ExampleProject.mdf as database 'ExampleProject'

Does that path look fishy? Shouldn't it be trying to attach the mdf file from the App_Data folder as database 'ExampleProject'? There is no mdf file in that location. Why is it looking there?

#300445
Edited, Apr 20, 2023 20:37
Vote:
 

I am not sure if you need to run dotnet episerver update-database anymore.

This thread which might help you in setting up -

https://world.optimizely.com/forum/developer-forum/cms-12/thread-container/2023/1/dotnet-episerver-create-cms-database-not-working/

Addtionally, You can try following steps in my blog if that helps you - 

https://world.optimizely.com/blogs/stackmanoz/dates/2022/3/updated-commands-to-install-commerce14-and-cms12/

If nothing works at all, We can connect and look at it together.

#300490
Apr 21, 2023 7:16
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.