Tag: entity-framework

Is it possible to create read-only synonym in SQL Server?

We have 2 different databases DB1 and DB2 with tables in DB2 referring to tables in DB1. We are looking into the possibility of using SYNONYMS with read-only access in DB2 and use EntityFramework to refer to these SYNONYMS as tables in DB2. Since currently EF doesn’t span across multiple databases, after reading this article […]

Entity framework join with a subquery via linq syntax

I’m trying to translate a sql query in linq sintax, but I’m having big trouble This is my query in SQL select * FROM dbo.ITEM item inner join ( select SUM([QTA_PRIMARY]) QtaTotale, TRADE_NUM, ORDER_NUM, ITEM_NUM from [dbo].[LOTTI] where FLAG_ATTIVO=1 group by [TRADE_NUM],[ORDER_NUM],[ITEM_NUM] ) TotQtaLottiGroupByToi on item.TRADE_NUM = TotQtaLottiGroupByToi.TRADE_NUM and item.ORDER_NUM = TotQtaLottiGroupByToi.ORDER_NUM and item.ITEM_NUM = […]

Design: Mixed XML / Relational or Pure Relational?

Is it acceptable to model a very complex object graph using XML in the database, but leave the rest of a system in relational tables? I’d like to gauge opinion on this as I’ve hit a bit of a conundrum. Many thanks ——————– Background I’m building a financial application which, although not at all large […]

Need to round decimal variable to round up in 2 decimal place while serializing into JSON using JSON.NET in C#

This question already has an answer here: Serializing a decimal to JSON, how to round off? 4 answers

Map Stored Procedure Result without Columns to a Model

I have a stored procedure that returns two columns without specifying their name, one is the ID (int) and the other one is a string. It is not possible for me to alter the stored procedure so that it can return the results with column names If I let Visual Studio to create the .edmx […]

EF 6 seamless connection with both Ms SQL and MySQL

I have ASP.NET MVC application with default MS SQL 2012 data source. I need to make same app to work with MySQL db without much code change or separate compilation since both database are exact replica. I have browsed and notice following solutions : Create separate SSDL using edmgen tool. – couldn’t complete implementation example […]

How can I call Include in Entity Framework after filter query

I’m trying call Include and loading related entities in EF !after WHERE query. How can I do this in EF? In SQL it’s looks like this: SELECT * FROM T1 INNER JOIN ( SELECT * FROM T WHERE … (filtering data)) as T2 ON T1.A = T2.A (loading data to filtered data) If i write […]

Entity framework connection string for WPF

Our application is currently connected to SQL CE but, we have to make it work with both SQL CE and SQL Express. We are using entity framework(model first). And its a windows application. How to write connection string for SQL Server? I found below on msdn site at http://msdn.microsoft.com/en-us/data/jj556606.aspx but, I am sure it won’t […]

Do rowversion/timestamp columns in SQL Server need a nonclustered index when using EF code-first?

All of my tables have a rowversion column that EF uses for optimistic concurrency checking. Should I create a nonclustered index on this column for faster data retrieval? Each table also has a clustered primary key named Id. Whenever updating data, will EF/SQL try to locate a row based on Id first and then run […]

Detached entities causing duplicate ID issues

I have very limited experience using EF4. I am successfully deserializing entities from a webservice in a detached state, and I now would like to save to the database. When SaveChanges is used I get the following exception: System.Data.UpdateException: An error occurred while updating the entries. See the inner exception for details. —> System.Data.SqlClient.SqlException: Violation […]

MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.