entity-framework-6

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

我与影子孤独终老i 提交于 2019-12-02 04:08:46
This question already has an answer here: Getting data from stored procedure with Entity Framework 4 answers 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 value with RETURN command at the end of the stored procedure. PROBLEM 1: my call returns -1 which is not even in the stored

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

≡放荡痞女 提交于 2019-12-02 04:02:46
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 my list of PK, I try find all data by PK var lServicosInformados = db.Servicos.Find(lCodigoServicos

The value's length for key 'data source' exceeds it's limit of '128'

╄→гoц情女王★ 提交于 2019-12-02 03:59:58
I know that a very similar question has been asked here , but the answer didn't help me. I am using Entity Framework 6 with the Oracle.ManagerDataAccess.Client. If I define the connection string in app.config, then the connection works. If I specify the identical connection string in code, then I get the error The value's length for key 'data source' exceeds it's limit of '128'. which is correct. This is my connection string (with some names removed): "User Id=xxxxxxxxxxx;Password=xxxx;Data Source=( DESCRIPTION = ( ADDRESS_LIST = ( ADDRESS = (PROTOCOL = TCP)(HOST = VS-ORACLE.xxxxxxx.de)(PORT =

How do I add properties to a Web API Response that I do not store in my DB?

白昼怎懂夜的黑 提交于 2019-12-02 03:53:31
I am building a C# Web API using Entity Framework 6.0. I have the simplest User Class with 3 properties that I persist on SQL into a User Table with 3 corresponding columns where UserID is its the Primary Key. public partial class User { public string UserID {get; set;} public string FirstName {get; set;} public string LastName {get; set;} } I want to add to the Web API two output-only properties on the fly that I do not care to store in my DB. I use these properties to communicate to the consuming client "Status" and "Message" information that are not part of the User Class. Status = OK|Error

EF6 entity with DatabaseGeneratedOption.Identity Guid Id force insert my Id value

蹲街弑〆低调 提交于 2019-12-02 03:23:00
I am trying to use EF to export/import the existing database of a DbContext. In this context, there are several entities with Guid Id properties with DatabaseGeneratedOption.Identity defined by the ModelBuilder. When I re-import the entities, I want to use the Id value from the serialized object, but it always generates a new Id value when I save the changes. Is there any way to force EF to use my Id value in this case? I know DatabaseGeneratedOption.None will allow me to do it, but then I will always be responsible for generating the Id. I know there segmentation issues of the index that

Dynamic Linq + Entity Framework: datetime modifications for dynamic select

让人想犯罪 __ 提交于 2019-12-02 03:06:05
问题 I am trying to find a way to move UTC time to Local before doing a sql grouping. I am using the System.Linq.Dynamic (managed here https://github.com/kahanu/System.Linq.Dynamic ). It works great for doing dynamic selects without having at compile time the required fields. In our case, we store all datetimes in UTC. In this dynamic select, its possible that someone would want to do a groupby on the Hour, year, month, etc. We have to move the data to a local time in this case, to prevent

“Unknown data type” error with Firebird embedded and Entity Framework 6

此生再无相见时 提交于 2019-12-02 01:25:56
问题 I'm using an embedded Firebird database with code first (Entity Framework 6). The first time the application runs, it works fine: the database gets created and the data gets inserted. But every time it runs after that, it throws the following exception: An exception of type 'System.NotSupportedException' occurred in FirebirdSql.Data.FirebirdClient.dll but was not handled in user code Additional information: Unknown data type The project includes the following NuGet packages: EntityFramework

Entity Framework and OFFSET/FETCH on Sql Server

浪尽此生 提交于 2019-12-02 01:24:27
I just encountered a weird bug in my app where a paged data grid contained duplicate rows. Investigation showed that it's because the new paging mechanism Entity Framework uses with Sql Server 2012 as of version 6.1.2 only works on strictly ordered column sets , as is documented here . Since most columns are not strictly ordered (meaning you have duplicate entries with respect to the sort order), simply binding one of the typical grid middlewares to Entity Framework is now broken subtly and horribly. I can't believe I'm the first to complain, but I did google! I found at least a dba

Entity Framework 6. Disable ModelCaching

大城市里の小女人 提交于 2019-12-02 00:54:04
OK, Google, I am not able to googling it. Documentation says The model for that context is then cached and is for all further instances of the context in the app domain. This caching can be disabled by setting the ModelCaching property on the given ModelBuidler and SO confirms it. But i can't find way to do it. I have to disable caching because i want to get data from several log table with same structure via just one model, so my code looks like logTableNames.ForEach(n => { using (var context = new LogContext(n)) { Console.WriteLine($"Project: {n} -- {context.Logs.Count()} rows.\n"); } });

How can you add a navigation property on a view in EF 6.1 CodeFirst

一笑奈何 提交于 2019-12-01 22:16:08
问题 Let's make a case to explain my problem. MyTable1 +id +myTable2Id MyTable2 +id MyView1 +id +myTable2Id MyView1 exists in the case, from data from the MyTable1. Now i want to create a Navigation property from my EF6.1 Code first approach in my View to MyTable2. I know that it was possible from the database first approach, but is it also possible from the code-first approach and how? EDIT: I search some on internet, but due many meanings of the word View, it's very hard to find information on