entity-framework-6

Error deploying to SQL Azure using EF 6 alpha3 Code First and Migrations creating __MigrationHistory table

浪尽此生 提交于 2019-12-14 01:32:09
问题 I'm using EF 6 alpha 3 code first. When I try to create the database on SQL Azure running the Update-Database command I get the following error: Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again. I tracked down the error to the __MigrationHistory table creation sql command. CREATE TABLE [dbo].[__MigrationHistory] ( [MigrationId] [nvarchar](255) NOT NULL, [ContextKey] [nvarchar](512) NOT NULL, [Model] [varbinary](max

Asp.Net MVC and Strategy pattern

时光毁灭记忆、已成空白 提交于 2019-12-13 22:04:16
问题 I have an MVC application that uses Entity Framework. I am using a repository, unit of work and unity as dependency injection. The problem I have is that I have different authentication types, and each type I want a different class, so I decided to use the Strategy pattern public interface IAuthStrategy { OperationResponse<AuthenticationMechanismDTO> GetAuthenticationMechanism(string userName); } public class AuthStrategy { readonly IAuthStrategy _authStrategy; public AuthStrategy

How to reflect the changing of my entities names to the navigation properties names

扶醉桌前 提交于 2019-12-13 21:24:51
问题 I have set of Entities generated according to DB First work flow in EntityFramework. The Entities have in proper names so i decide to change them but when i change the Entity name, the navigation property keeps the pluralization and the singularization of the old name like the following : Two Entities ( SREmp ,SRPic ) SREmp SRPic Id id name content phone note - - - - - - SRPics SREmp Now when i change the names of my entities to ( Employee,EmpPhoto ), the navigation properties didn't change !

EF6 Code First: Login Failing on update-database

邮差的信 提交于 2019-12-13 19:40:49
问题 I am trying to do an update-database on an EF6 code first database. All I've done is build my models and the datacontext, run enable-migrations and did an add-migration InitialCreate. That all worked well. But the update-database is failing in two different ways. For a while I had it working, but it was creating the database files (i.e., the MDF and log files) under c:\Users\. I don't want them there. I want them in the App_Data folder of an MVC website I'm building (the database schema is in

Exclude certain entities from second-level caching

女生的网名这么多〃 提交于 2019-12-13 19:22:05
问题 I'm using EFCache to provide 2nd-level caching in my EF context. I ran into a problem, where one of my entities is connected to a view which provides row-level security. So this view filters rows based on some parameters. When using 2nd-level cache, all users will get the same result! I'm looking for a way to exclude certain entities from caching, any help is welcome. This is my caching configuration: class CacheConfiguration : DbConfiguration { public CacheConfiguration() { var

entity framework 6 and pessimistic concurrency

坚强是说给别人听的谎言 提交于 2019-12-13 17:22:56
问题 I'm working on a project to gradually phase out a legacy application. In the proces, as a temporary solution we integrate with the legacy application using the database. The legacy application uses transactions with serializable isolation level. Because of database integration with a legacy application, i am for the moment best off using the same pessimistic concurrency model and serializable isolation level. These serialised transactions should not only be wrapped around the SaveChanges

Using Func as parameter for LinqToEntities

一个人想着一个人 提交于 2019-12-13 16:26:26
问题 I have a Linq-Query to get my EF-Data. My query joins 4 tables and selects the result to a denormalized type. I will need this query very often but with different predicates. The List-ExtensionMethods (e.g. .Where() are working with a Func<T,bool> as a parameter and I wanted to do it the same - but I don´t find a way to access my predicate in my Method. public DenormalizedType GetData(Func<Thing, bool> predicate) { using (var dbContext = new MyDbContext()) { var myData = (from some in

Generating an EDMX from a DB2 Database

安稳与你 提交于 2019-12-13 15:41:38
问题 I'm trying to create an EDMX file using VS2013 so I can read/write from a DB2 Database. I go through the same process as creating the EDMX from my SQL tables (Right click on project -> Add New Item -> ADO.NET Entity Data Model -> EF Designer from database -> Not using SQL this time so: new connection -> Change data source) but in the Data Source option, DB2 is not available. I have 2 SQL options and that's it. Data Source So after doing some investigating around here along with some other

How to create multi-columns “reference” index (join index) in c# model with EF6

点点圈 提交于 2019-12-13 15:40:52
问题 I know how to create common multi-columns index in c# which is mapping table in database. But I encounter one specifical question on Multiple columns index, here is the code: public class Table1 { [Index("MultipleIndexColumn",1)] public Table2 Table2_ID {get; set;} [Index("MultipleIndexColumn",2)] public Table3 Table3_ID {get; set;} [Index("MultipleIndexColumn",3)] public DateTime CreateDateTime {get; set;} } EF6 will generate t-sql like this : create index MultipleIndexColumn on Table1

Entity Framework Filtered Navigation Properties

空扰寡人 提交于 2019-12-13 15:35:24
问题 Is there a way to set a filter on a navigation property using EF6/code first? I want to achieve something similar to the below, where Farm.Pigs returns a collection of animals whose type is equal to pig (but without loading the whole collection from the database first - and not storing them in a separate table). Is this possible? public class Farm { public int Id { get; set; } public virtual ICollection<Animal> Pigs { get; set; } public virtual ICollection<Animal> Cows { get; set; } } public