dbcontext

Storing data between requests in dbcontext

*爱你&永不变心* 提交于 2020-02-20 08:06:25
问题 I have a page with server side rendering using razor, where you can add a couple of elements from different lists, fill some fields and create a request from it on submit. Each time an item is added/taken from any list, I send a post with submit button to a specific action, e.g. "CustomerSelected". I do this, because I need to recreate additional view components for the added item. In these methods I would like to add added objects to the db context, so on submit I can just say SaveChanges()

Storing data between requests in dbcontext

依然范特西╮ 提交于 2020-02-20 08:06:08
问题 I have a page with server side rendering using razor, where you can add a couple of elements from different lists, fill some fields and create a request from it on submit. Each time an item is added/taken from any list, I send a post with submit button to a specific action, e.g. "CustomerSelected". I do this, because I need to recreate additional view components for the added item. In these methods I would like to add added objects to the db context, so on submit I can just say SaveChanges()

Manually Provide DbContext to DbMigrator

十年热恋 提交于 2020-01-31 15:07:12
问题 Platform .NET 4.5 and Entity Framework 6. Question I have the following code to execute a Migration: //The following function just returns an object of the Configuration() class //generated by code migrations var migratorConfig = currentMigrationProvider.CreateDbMigrationConfiguration(); var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(migratorConfig); dbMigrator.Update(); The problem is that Update() function tries to create an instance of my DbContext class and for a few good

Manually Provide DbContext to DbMigrator

会有一股神秘感。 提交于 2020-01-31 15:06:53
问题 Platform .NET 4.5 and Entity Framework 6. Question I have the following code to execute a Migration: //The following function just returns an object of the Configuration() class //generated by code migrations var migratorConfig = currentMigrationProvider.CreateDbMigrationConfiguration(); var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(migratorConfig); dbMigrator.Update(); The problem is that Update() function tries to create an instance of my DbContext class and for a few good

Manually Provide DbContext to DbMigrator

邮差的信 提交于 2020-01-31 15:04:27
问题 Platform .NET 4.5 and Entity Framework 6. Question I have the following code to execute a Migration: //The following function just returns an object of the Configuration() class //generated by code migrations var migratorConfig = currentMigrationProvider.CreateDbMigrationConfiguration(); var dbMigrator = new System.Data.Entity.Migrations.DbMigrator(migratorConfig); dbMigrator.Update(); The problem is that Update() function tries to create an instance of my DbContext class and for a few good

Unable to register DbConnection with Unity and Entity Framework

旧巷老猫 提交于 2020-01-25 01:07:45
问题 I am not at all sure what the underlying problem is that is causing this exception. I am using ASP.NET MVC, with Unity.Mvc, and Entity Framework 6. I have the following code to register my repositories: public static void RegisterTypes(IUnityContainer container) { // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements. // container.LoadConfiguration(); // TODO: Register your types here // container

Unable to register DbConnection with Unity and Entity Framework

不羁的心 提交于 2020-01-25 01:07:10
问题 I am not at all sure what the underlying problem is that is causing this exception. I am using ASP.NET MVC, with Unity.Mvc, and Entity Framework 6. I have the following code to register my repositories: public static void RegisterTypes(IUnityContainer container) { // NOTE: To load from web.config uncomment the line below. Make sure to add a Microsoft.Practices.Unity.Configuration to the using statements. // container.LoadConfiguration(); // TODO: Register your types here // container

Setup one to many relation with fk having multiple rows

不羁的心 提交于 2020-01-24 13:55:52
问题 I have a problem with setting up a one-to-many relation with EF Core. I have two tables address and address_country . There are schemas: As you see, I want to store countries with different locales. So it has a composed key. address table has a foreign key to address_country . Unfortunately, I cannot setup ContextDb to achieve what I want. The list of countries is not filled in Address model. I have the following code in Context : public class Context : DbContext { protected override void

How to configure hangfire with ASP.NET to obtain connection string from config file?

我们两清 提交于 2020-01-21 09:42:05
问题 Please forgive me this probably stupid question, I am still not too familiar with the ASP.NET architecture in general. I inherited a large project, and I intend to setup hangfire.io. I understand that I have to somehow initialize the DB context, but I do not want to hardcode it as suggested by the hangfire-docu. My API\Global.asax.cs currently looks as follows, the interesting stuff begins after // Hangfire stuff : using System.Web.Http; using System.Web.Http.ExceptionHandling; using System

Access DB context through SignalR Core

女生的网名这么多〃 提交于 2020-01-21 09:19:25
问题 I'm using AspNetCore.SignalR and I need advice on how to access my SQL Server database through my Hub. There are not a lot of resources out there about this. I know how to add a singleton but I do not know how to access it later. How can I access a DB context that is defined using a Configuration.GetConnectionString in Startup.cs inside my Hub's Tasks? Thanks. Here's the relevant code: Startup.cs public void ConfigureServices(IServiceCollection services) { services.Configure