Quantcast
Channel: ASP.NET Core
Viewing all articles
Browse latest Browse all 9386

dnx to dotnet

$
0
0

I am trying to do the first migration, but it gives me an error

with with rc1, I had no problem donin it this way

Model:

    public class Product
    {
        public int productiD { get; set; }
        public String name { get; set; }
    }

DbContext:

    public class yoContext : DbContext
    {
        public DbSet<Product> Products { get; set; }
    }

Startup:

            // Add framework services.
            services.AddDbContext<ApplicationDbContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")))
                .AddDbContext<yoContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

when I use this in the command line:

dotnet ef migrations add First -c yoContext

This is the error that I get, if I do almost the same thing in asp.net it Works fine

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.


Viewing all articles
Browse latest Browse all 9386

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>