Skip to content

Using a DB Context that Extends IdentityDbContext<TUser, TRole, TKey> where TKey: Guid causes an error on add migration #2099

@mgolus

Description

@mgolus

If using a DB Context that extends IdentityDbContext<TUser, TRole, TKey> and TKey is a Guid or an int, the following error happens on add migration:

"No data stores are configured. Configure a data store by overriding OnConfiguring in your DbContext class or in the AddDbContext method when setting up services."

This can be repeated by starting with a ASP.Net 5 web project created with Visual Studio 2015 RC and using the ApplicationUser and Role models and the ApplicationDbContext shown below:

public class ApplicationUser : IdentityUser<Guid>
{
    public ApplicationUser()
    {
    }
}

public class ApplicationRole : IdentityRole<Guid>
{
    public ApplicationRole()
    {
    }
}

public class ApplicationDbContext : IdentityDbContext<ApplicationUser, ApplicationRole, Guid>
{
  ...
}

And initializing the service in the Startup.cs file by using

services.AddEntityFramework()
            .AddSqlServer()
            .AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions