Entity Framework: One Database, Multiple DbContexts. Is this a bad idea? [closed]

Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago. Improve this question My impression to date has been that a DbContext is meant to represent your database, and … Read more

Entity Framework Core add unique constraint code-first

I can’t find way to add a unique constraint to my field with using attribute: public class User { [Required] public int Id { get; set; } [Required] // [Index(“IX_FirstAndSecond”, 2, IsUnique = true)] not supported by core public string Email { get; set; } [Required] public string Password { get; set; } } I’m … Read more

No connection string named ‘MyEntities’ could be found in the application config file

I am using entity framework and ASP.NET MVC 4 to build an application My solution is split into two projects; A class library that includes my data model (.edmx) file and a few custom interfaces The ‘container’ MVC project that references the class library above My problem is that when I attempt to use the … Read more

Using MySQL with Entity Framework [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 2 years ago. Improve this question Can’t find anything relevant about Entity Framework/MySQL on Google so I’m hoping someone knows about it. 10 Answers 10

Entity Framework and Connection Pooling

I’ve recently started to use the Entity Framework 4.0 in my .NET 4.0 application and am curious about a few things relating to pooling. Connection pooling as I know is managed by the ADO.NET data provider, in my case that of MS SQL server. Does this apply when you instantiate a new entities context (ObjectContext), … Read more

Non-static method requires a target

I have a controller action that works fine on Firefox both locally and in production, and IE locally, but not IE in production. Here is my controller action: public ActionResult MNPurchase() { CalculationViewModel calculationViewModel = (CalculationViewModel)TempData[“calculationViewModel”]; decimal OP = landTitleUnitOfWork.Sales.Find() .Where(x => x.Min >= calculationViewModel.SalesPrice) .FirstOrDefault() .OP; decimal MP = landTitleUnitOfWork.Sales.Find() .Where(x => x.Min >= … Read more

What does principal end of an association means in 1:1 relationship in Entity framework

public class Foo { public string FooId{get;set;} public Boo Boo{get;set;} } public class Boo { public string BooId{get;set;} public Foo Foo{get;set;} } I was trying to do this in Entity Framework when I got the error: Unable to determine the principal end of an association between the types ‘ConsoleApplication5.Boo’ and ‘ConsoleApplication5.Foo’. The principal end of … Read more

How to call Stored Procedure in Entity Framework 6 (Code-First)?

I am very new to Entity Framework 6 and I want to implement stored procedures in my project. I have a stored procedure as follows: ALTER PROCEDURE [dbo].[insert_department] @Name [varchar](100) AS BEGIN INSERT [dbo].[Departments]([Name]) VALUES (@Name) DECLARE @DeptId int SELECT @DeptId = [DeptId] FROM [dbo].[Departments] WHERE @@ROWCOUNT > 0 AND [DeptId] = SCOPE_IDENTITY() SELECT t0.[DeptId] … Read more