entity-framework-6

could not load file or assembly 'microsoft.sqlserver.management.sdk.sfc version=11.0.0.0

时光怂恿深爱的人放手 提交于 2019-12-12 11:26:52
问题 I am using Database first approach of Entity framework. When I create new connection in "ADO.NET Entity Data Model" then after adding server name and database name, then it shows me this error - Could not load file or assembly 'Microsoft.SqlServer.Management.Sdkc.Sfc, Version=11.0.0.0, Culture=neutral, PublicKey Toekn = 89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified. Found many links on Google and tried but it doesn't solve my issue. Could not load

Entity Framework 6 Creating Two table from the same entity object

空扰寡人 提交于 2019-12-12 11:14:59
问题 I was wondering if it's possible to create two table instance from one defined entity object class. Example: public class EntityA() { public String name {get; set;} public String value {get; set;} } public class MyDbConext : DbContext { public DbSet<EntityA> instance1{ get; set; } public DbSet<EntityA> instance2{ get; set; } } What i'm trying to do is create two instances of Entity A with different table names. Is that possible with code first entity framework? I feel like it's seems tedious

Is there a way to have ASP.NET 5 Dependency Injection resolve a DbContext without a reference?

左心房为你撑大大i 提交于 2019-12-12 10:55:38
问题 I am doing some prototyping with MVC 6 and have run into a quandary. Our project architecture is straightforward enough: Data Tier (Entity Framework 6) Service Tier (Class Library, references Data Tier) Presentation Tier (MVC 4, references Service Tier, does not reference Data Tier) I'm attempting to keep the design as similar to the original as possible, even after reading (and agreeing with) the Composition Root pattern. This means that my new MVC 6 application is unaware of my DbContext

EF: How to execute a SQL-query with multiple joins?

蓝咒 提交于 2019-12-12 10:13:42
问题 Im working with Entity Framework version 6.1.3 and I want to execute a SQL-query which gathers information from multiple tables like this: var result = context.Database.SqlQuery<SomeType>("SELECT SUM(d.PurchaseValue) AS 'Total', div.Name, l.Name " + "FROM Device AS d " + "RIGHT JOIN Location AS l " + "ON d.LOCATION_ID = l.ID " + "RIGHT JOIN Division AS div " + "ON d.DIVISION_ID = div.ID " + "GROUP BY div.Name, l.Name " + "ORDER BY l.Name"); My question is, what should be the the type in

Define SQL table primary key as case sensitive using Entity Framework Code First

丶灬走出姿态 提交于 2019-12-12 09:57:45
问题 Is it possible to define a SQL case sensitive primary key in entity framework code first? I know that by default SQL is case insensitive when it comes to strings, just to be clear I don't want to change the entire DB definition to case sensitive, just one table column (primary key). I'm getting data from an external API which sends the data with case sensitive primary keys ('a' and 'A' are different records), I know I can modify them and save them differently in my DB, but this will also

How do I resolve issues with unsupported DateTimeOffsets in EF 6 using Sql Server?

泪湿孤枕 提交于 2019-12-12 09:18:57
问题 When I try to instantiate a DbContext I receive this message: System.NotSupportedException: There is no store type corresponding to the conceptual side type 'DateTimeOffset' of primitive type 'DateTimeOffset'. I am using Entity Framework version 6 on SQL Server. The constructor of the DbContext (with the line that throws the exception) looks like this: internal TestHubContext(string connectionStringName) : base(connectionStringName) { var objectContext = (this as IObjectContextAdapter)

EntityFramework Stored Proc Function Import is it possible to read async?

安稳与你 提交于 2019-12-12 08:43:57
问题 I'm using EF 6.1.1 and Database First. When I import a stored proc into the edmx and generate the DBContext it looks like this: return ((IObjectContextAdapter)this).ObjectContext.ExecuteFunction<TestSP_Result>("TestSP", params[]...) That returns an ObjectResult< T >, which implements IDbAsyncEnumerable< T > so I'm doing this to read the data async: IDbAsyncEnumerable<T> enumerable = objectResult as IDbAsyncEnumerable<T>; IDbAsyncEnumerator<T> enumerator = enumerable.GetAsyncEnumerator(); List

Entity Framework “An entity object cannot be referenced by multiple instances of IEntityChangeTracker”

僤鯓⒐⒋嵵緔 提交于 2019-12-12 08:39:22
问题 I am getting the error An entity object cannot be referenced by multiple instances of IEntityChangeTracker when trying to create a new entity and save it to the DB. I understand the error and how it normally occurs, but in this instance all I am doing is creating a new entity and adding a few int s to it before saving, not adding any other entities from other contexts. I have included the function that is causing the error. As you can see it is being passed an EndProduct which is an entity

Query Xml from SQL using Entity Framework Database First

半城伤御伤魂 提交于 2019-12-12 07:38:04
问题 I need to use Entity Framework, LINQ to query the XML data from the SQL in my asp.net mvc(C#) application. I have a column XMLValue with data <MetaData> <Reviews>1</Reviews> <Rating>1</Rating> </MetaData> I need to get all the Customers who have a Rating of 1 from the xml. I have referred to this stackoverflow post and I am not able to achieve it. I have added the SQL function and added it to my edmx: CREATE FUNCTION [dbo].[FilterCustomersByRating] (@Rating int) RETURNS TABLE AS RETURN SELECT

Entity Framework does not generates ObservableCollection

ε祈祈猫儿з 提交于 2019-12-12 07:37:17
问题 Im using EF6 in my dataentry program. EF does not generates ObservableCollection but HashSet and ICollection instead , so i have to change it manually. Unfortunately every time i Update Model from Database , every Many-Many relation goes back to ICollection ... 回答1: Replace ICollection and HashSet with ObservableCollection in your .tt file. Then search for the method public string UsingDirectives . In this method there should be a line includeCollections ? (Environment.NewLine + "using System