entity-framework-6

Error when generating database from model in Visual Studio 2013

天大地大妈咪最大 提交于 2019-12-02 18:11:31
问题 I have installed VS2013 but still have VS2012. In VS2013 I cannot generate a database from a model in Entity Framework. I get the following error message: The files in the error message do exist! Does anyone have any idea how I can fix this? 回答1: Your tip about checking the drive made me see what I should have seen before. The environment variable VS120COMNTOOLS had the wrong drive letter. Can't remember, but I initially installed VS2013 on another drive and then changed it back to C. Anyway

Entity Framework query performance differs extrem with raw SQL execution

孤者浪人 提交于 2019-12-02 18:08:51
I have a question about Entity Framework query execution performance. Schema : I have a table structure like this: CREATE TABLE [dbo].[DataLogger] ( [ID] [bigint] IDENTITY(1,1) NOT NULL, [ProjectID] [bigint] NULL, CONSTRAINT [PrimaryKey1] PRIMARY KEY CLUSTERED ( [ID] ASC ) ) CREATE TABLE [dbo].[DCDistributionBox] ( [ID] [bigint] IDENTITY(1,1) NOT NULL, [DataLoggerID] [bigint] NOT NULL, CONSTRAINT [PrimaryKey2] PRIMARY KEY CLUSTERED ( [ID] ASC ) ) ALTER TABLE [dbo].[DCDistributionBox] ADD CONSTRAINT [FK_DCDistributionBox_DataLogger] FOREIGN KEY([DataLoggerID]) REFERENCES [dbo].[DataLogger] ([ID

update the database from package manager console in code first environment

两盒软妹~` 提交于 2019-12-02 17:34:10
Code First Environment I'm trying to update the database from package Manager console.If my Domain class change, I have to drop and create the database,Instead of dropping the Database how can i update the database. I have already try by reading some blogs in google. commands PM> Install-Package EntityFramework By using this command i install the Entity Framework successfully. PM> Enable-Migrations By using this command it created the Migration file in my project. PM> Update-Database By using this command , i may update the table but i have a Problem here . Error Specify the '-Verbose' flag to

EF6 Code First with generic repository and Dependency Injection and SoC

℡╲_俬逩灬. 提交于 2019-12-02 16:23:43
After a lots of reading and trying things out with Entity Framework latest stable version (6.1.1). I'm reading lots of contradictions about whether or not to use repositories with EF6 or EF in general, because it's DbContext already provides a repository and DbSet the UoW , out of the box. Let me first explain what my solution contains in terms of project and then I'll comeback at the contradiction. It has a class library project, and an asp.net-mvc project. The class lib project being the data access and where Migrations are enabled for Code First . In my class lib project I have a generic

The type appear in two structurally incompatible initializations within a single LINQ to Entities query

∥☆過路亽.° 提交于 2019-12-02 15:05:32
问题 I am trying to get the record from multiple tables the last two tables have relation with so i make a join between them but first table has no relation with them but i need to get the data from it. This is my ViewModel public class AssignTodoVM { public int TOdoPresetTeamID { get; set; } public int UserId { get; set; } public int TaskId { get; set; } public string TaskName { get; set; } public DateTime CreatedDate { get; set; } public string userName { get; set; } public int? TeamId { get;

Entity Framework inserting duplicates on Seeding database [duplicate]

我只是一个虾纸丫 提交于 2019-12-02 14:56:33
问题 This question already has an answer here : Entity Framework database mapping relationships (Duplicate creation using Seed() method) (1 answer) Closed 12 months ago . EDIT---- From here i tried assigning Id's in the seeding method and this was OK for Languages but not when i added Address to the customer and assign Id's as well to these addresses, than it created the dupes again... Both Address & Language are declared as DbSet<...> in my Context What i tried: Adding 1 Address (with Id) - add

Entity Framework 6 Cannot build after adding stored procedures to data model

对着背影说爱祢 提交于 2019-12-02 14:22:51
I just downloaded entity framework 6 and created a brand new project to test it. We currently use EF 5. After adding all my tables and stored procedures, I tried to build the project but I get errors: Value of type 'System.Data.Objects.ObjectParameter' cannot be converted to 'System.Data.Entity.Core.Objects.ObjectParameter'. Value of type 'System.Data.Entity.Core.Objects.ObjectResult(Of DataLibrary.MyStoredProc_Result)' cannot be converted to 'System.Data.Objects.ObjectResult(Of DataLibrary.MyStoredProc_Result)'. I cannot figure out why this will not work out-of-the-box EF 5 had so such issues

Linq to Entities performance and pregenerating views

怎甘沉沦 提交于 2019-12-02 14:05:20
问题 We are taking a long time on first runs of our linq to EF queries. I was surprised to see no difference after pre-generating views. I ran across the following claim on stackoverflow View generation only helps for "standard" queries (e.g., when you call someObject.RelatedEnd.Load() or MyContext.SomeSetName(). It doesn't help for ad hoc queries with LINQ or ESQL, for obvious reasons. Use CompiledQuery to optimize those. When he says "for obvious reasons" I have to say, "Well,not obvious to me

Entity Framework (Database first) has incorrect return result from stored procedure [duplicate]

喜你入骨 提交于 2019-12-02 13:58:18
问题 This question already has answers here : Getting data from stored procedure with Entity Framework (4 answers) Closed 2 years ago . Environment: Visual Studio 2017 SQL Server 2016 EF v6 with a database-first approach Background: the stored procedure is in the EDMX. My stored procedure sets the return value to 0 if nothing happened, 1 if something affected and value of @@ERROR if errors. BACKGROUND 1: my stored procedure, LTM_Lease_DeleteSubFiles , does SET NOCOUNT ON at the top and sets return

How to find a List<Object> using Find method of entity framework passing Array as parameter?

試著忘記壹切 提交于 2019-12-02 13:33:33
问题 I would like to know how to find a List<Object> using Find method of Entity Framework passing Array( object[] ) as parameter? I want to find all data by Primary Key. I first fill a list with all PK that I will use as reference: List<int> lCodigoServicos = new List<int>(); foreach (ServicosSelecionadosModelView servicoSelecionado in lServicos.FindAll(s => !string.IsNullOrEmpty(s.selecionado) && s.selecionado.ToLower() == "on" )) lCodigoServicos.Add(servicoSelecionado.servico.SerId); After fill