hi folks,
I am referring to CRUD for controller and View with ASP.NET 5 and MVC 6.
Models/BookContext.cs:
public class BookContext : DbContext { public DbSet<Author> Authors { get; set; } public DbSet<Book> Books { get; set; } }
Project.json
"dependencies": { .................................... "EntityFramework.Core": "7.0.0-beta5","EntityFramework.SqlServer": "7.0.0-beta5","EntityFramework.Commands": "7.0.0-beta5","Microsoft.Framework.CodeGenerators.Mvc": "1.0.0-beta5" },"commands": {"web": "Microsoft.AspNet.Hosting --config hosting.ini","ef": "EntityFramework.Commands","gen" : "Microsoft.Framework.CodeGeneration" },
Config.json
{"Data": {"ConnectionString": "Server=(localdb)\\MSSQLLocalDB;Database=ContosoBooks123;Trusted_Connection=True;MultipleActiveResultSets=true" } }
Startup.cs
................................. public void ConfigureServices(IServiceCollection services) { services.AddMvc(); services.AddEntityFramework() .AddSqlServer() .AddDbContext<BookContext>(options => { options.UseSqlServer(Configuration.Get("Data:ConnectionString")); }); } .................................
I have created a database after i run the data migrations command and it seems good. now i run the following command:
dnx . gen controller -name BookController --dataContext BookContext --model Book
I am getting error message but not just error message and it says:
Finding the generator 'controller'... Running the generator 'controller'... Attempting to figure out the EntityFramework metadata for the model and DbContext 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.
I do not understand. My Database Context is seem ok.
What am i missing?
Thanks in advance