I have a started a new ASP.NET Core 2.0 project and I use the the Entity Framework with Identity.
The starting database schema consists from the following tables:
Everything works as expected with the current schema and I didn't have any problems with the existing datatable operations.
Now I want to alter the database schema. I want to add some new tables but I am finding it difficult to find some documentation to help me understand the way to do it.
For now I am following the "Create an app with user data protected by authorization" and I started from creating a new model to my application.
After creating a new model and scaffolding the Controller for this model a new Context was created in my appsettings.json. I just had the DefaultConnection and now was added the esendContext.
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-esend-069757D7-82B1-4850-8015-07D7D54AA712;Trusted_Connection=True;MultipleActiveResultSets=true",
"esendContext": "Server=(localdb)\\mssqllocaldb;Database=esendContext-25459d27-29ec-4943-ac91-6b9cb91a0dd6;Trusted_Connection=True;MultipleActiveResultSets=true"
When I hit the new url I get the following message:
I understand that I should apply the migrations but I wonder why do I get the SqlException: Cannot open database ....
error
Furthermore when I try to apply the migration (Add-Migration Initial -Context esendContext according to this since I got an error about the context I should use) according to documentation in the PMC
Install-Package Microsoft.EntityFrameworkCore.Tools
Add-Migration Initial
Update-Database
when I try to update the database I get
An error occurred while calling method 'BuildWebHost' on class 'Program'. Continuing without the application service provider. Error: Could not load file or assembly 'Microsoft.EntityFrameworkCore, Version=2.0.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
No DbContext was found in assembly 'esend'. Ensure that you're using the correct assembly and that the type is neither abstract nor generic.
I am not really sure If this is the procedure I should be following. Any help or link for something that could help would be greatly appreciated and excuse me If I have stated too many issues in one question.