Пример #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, WebapiContext context, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //log
            loggerFactory.AddDebug();

            // ===== Use Authentication ======
            app.UseAuthentication();
            app.UseMvc();

            // ===== Create tables ======
            context.Database.EnsureCreated();
        }
Пример #2
0
        private static void InsertData()
        {
            using (var context = new WebapiContext())
            {
                // Creates the database if not exists
                context.Database.EnsureCreated();

                // Adds an user
                var user = new User
                {
                    id   = 35,
                    name = "My Books"
                };
                // context.User.Add(user);

                // Saves changes
                context.SaveChanges();
            }
        }