You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running dotnet ef migrations add initial or dotnet ef database update I get:
Unable to resolve service for type 'Microsoft.EntityFrameworkCore.Migrations.IMigrator'. This is often because no database provider has been configured for this DbContext. A provider can be configured by overriding the DbContext.OnConfiguring method or by using AddDbContext on the application service provider. If AddDbContext is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.
The error is the same even if I add a design time factory. My DB context class like this:
namespace Proj.Data
{
public class ApplicationDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
{
public ApplicationDbContext CreateDbContext(string[] args)
{
DbContextOptions options = new DbContextOptionsBuilder().UseCosmosSql(
new Uri("https://uri.documents.azure.com:443/"),
"key",
"db-name")
.Options;
return new ApplicationDbContext(options);
}
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions options)
: base(options)
{
}
public DbSet<Customer> Customers { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<Customer>()
.HasIndex(t => new {t.Id})
.IsUnique();
}
}
}
What is wrong with this class? Is there an article I can follow as an example to get this working?
The text was updated successfully, but these errors were encountered:
@jcagme Migrations are designed around relational databases and hence IMigrator is not available. Issue #6983 is tracking a better exception message for these cases. We do have ideas around evolving the document database, but these will likely not look like relational migrations.
We will be blogging about Cosmos DB very soon. This should help showing how to use it and what currently works. Please keep in mind that this is still very much a preview and many things are not yet supported.
@umar-qureshi2 Migrations are a relational concept. There is no support for them when using the Cosmos provider. We have some ideas for things we might be able to do in the future around similar scenarios, but that is beyond the current goals for the Cosmos provider.
I'm using Microsoft.EntityFrameworkCore.Cosmos.Sql Version 2.2.0-preview1-35029 for EF driven identity in asp.net core 2.1.
I've added identity to some projects in the past but this is the first attempt using CosmosDb. Pretty much, I've done what is described here: https://docs.microsoft.com/en-us/aspnet/core/security/authentication/identity?view=aspnetcore-2.1.
When running
dotnet ef migrations add initial
ordotnet ef database update
I get:The error is the same even if I add a design time factory. My DB context class like this:
What is wrong with this class? Is there an article I can follow as an example to get this working?
The text was updated successfully, but these errors were encountered: