I'm trying to create an instance of my database on an actual SQL Server rather than just locally hosted, but every time I try and create a migration they're coming back empty...
public partial class InitialMigration0 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
Here is my appsettings.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server={dbName};Trusted_Connection=True;MultipleActiveResultSets=true;"
// "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=MLD-1ED06986-5F07-4A1C-85B9-D9F3F477BFF5;Trusted_Connection=True;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"AllowedHosts": "*"
}
And my AppDbContext:
namespace MLD.Models
{
public class AppDbContext : IdentityDbContext<IdentityUser>
{
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options)
{
}
//public DbSet<User> Users { get; set; }
public DbSet<LymphSite> LymphSites { get; set; }
public DbSet<Measurement> Measurements { get; set; }
public DbSet<Circumference> Circumferences { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
}
}
}
Any ideas why this is coming back empty? It worked fine for my localDb and it's connected to the SQL Server, but without anything coming up in the migrations it can't create tables so I'm at a bit of a loss!
Thanks in advance
Connection string solution:
I needed to add Integrated security to my connection string, user Id and password were not needed in this instance - when using User Id and password the user created did not have permissions to create database
{
"ConnectionStrings": {
"DefaultConnection": "Server={server name}; Database=Z_MyDiary;MultipleActiveResultSets=true; Integrated Security=true;"
},
Fix for migrations issue: x
Not a clue why the migrations were going wrong in the first place but they work now!