entity-framework-6

UOW - A second operation started on this context before a previous asynchronous operation completed

一笑奈何 提交于 2019-11-29 09:21:46
I am trying following code, it has two parts, one is navigation via prism. When navigation is allowed I am starting a deep load asynchronously but each time with a new context. In later code I would want to cancel pending navigations that are not finished this loading but the below code does not even work so cancellation is a matter for later ;-) navigation logic : no problems here public void OnNavigatedTo(NavigationContext navigationContext) { int relatieId = (int)navigationContext.Parameters["RelatieId"]; if (_relatie != null && _relatie.RelatieId == relatieId) return; loadRelatieAsync

The Include path expression must refer to a navigation property defined on the type.in eager loading

六月ゝ 毕业季﹏ 提交于 2019-11-29 09:20:42
I try to include anonymous type like this : I want all incomelist attributes in addition to CompanyTitle , PeriodTypeName ) var incomeList = ctx.IncomeLists.Include(i => new { CompanyTitle = i.CompanyId.ToString() + "/" + i.Company.CompanyName, PeriodTypeName = i.ListPeriods.Select(lp => lp.PeriodType.PeriodTypeName) }).ToList() My model section like this : but i get the following exception : The Include path expression must refer to a navigation property defined on the type. Use dotted paths for reference navigation properties and the Select operator for collection navigation properties.

Entity Framework 6: Code First Cascade delete

假装没事ソ 提交于 2019-11-29 09:19:27
So there are several similar questions on here to this, but I'm still having issues determing what exactly I'm missing in my simplified scenario. Let's say I have the following tables, cleverly named after myself: 'JohnsParentTable' (Id, Description) 'JohnsChildTable' (Id, JohnsParentTableId, Description) With the resulting classes looking like so public class JohnsParentTable { public int Id { get; set; } public string Description { get; set; } public virtual ICollection<JohnsChildTable> JohnsChildTable { get; set; } public JohnsParentTable() { JohnsChildTable = new List<JohnsChildTable>(); }

The type 'Company.Model.User' and the type 'Company.Core.Model.User' both have the same simple name of 'User' and so cannot be used in the same model

杀马特。学长 韩版系。学妹 提交于 2019-11-29 09:03:46
I have a base entity class MyCompany.Core.Model.User which is to be used for common properties of a User entity: public class User { public string Username { get; set; } public string Usercode { get; set; } } I also have a base mapping class MyCompany.Core.Model.UserMap to setup the code first mappings for the base User class: public class UserMap<TUser> : EntityMapBase<TUser> where TUser : User { public UserMap() { // Primary Key this.HasKey(t => t.Usercode); // Table & Column Mappings this.ToTable("Users"); this.Property(t => t.Username).HasColumnName("Username"); this.Property(t => t

Offset/Fetch based paging (Implementation) in EntityFramework (Using LINQ) for SQL Server 2008

依然范特西╮ 提交于 2019-11-29 08:34:04
I am using SQL Server 2008 and Entity Framework 6.1.3. I wish to implement pagination of data based on OFFSET/FETCH rather than Take() & Skip(). I searched online with no luck. Some posts suggested migrating to SQL Server 2012. Which is not an option in my case. Can someone suggest how to use OFFSET/FETCH with SQL Server 2008 and EF 6.1.3 This is possible with Entity Framework 6.1.2 and above so you should be OK to use it in your project. The standard Skip and Take methods can't be captured in the same way as others. There are now two additional overload of the Skip/Take methods that take

Offset/Fetch based paging (Implementation) in EntityFramework (Using LINQ) for SQL Server 2008

蹲街弑〆低调 提交于 2019-11-29 08:32:16
I am using SQL Server 2008 and Entity Framework 6.1.3. I wish to implement pagination of data based on OFFSET/FETCH rather than Take() & Skip(). I searched online with no luck. Some posts suggested migrating to SQL Server 2012. Which is not an option in my case. Can someone suggest how to use OFFSET/FETCH with SQL Server 2008 and EF 6.1.3 This is possible with Entity Framework 6.1.2 and above so you should be OK to use it in your project. The standard Skip and Take methods can't be captured in the same way as others. There are now two additional overload of the Skip/Take methods that take

Entity Framework : Sharing entities across different DbContexts

梦想与她 提交于 2019-11-29 08:20:26
问题 I'm developing a plugin application with EF6, code first. I have one main context with an entity called User : public class MainDataContext : DbContext { public MainDataContext(): base("MainDataContextCS") {} public DbSet<User> Users { get; set; } } And then another context for PluginX, on another project which references the base one: public class PluginDataContext : DbContext { public PluginDataContext () : base("MainDataContextCS") { } protected override void OnModelCreating(DbModelBuilder

Can Entity Framework 6 migrations include a transaction around scripts?

空扰寡人 提交于 2019-11-29 07:28:42
Very simple question, i am using migrations in entity framework 6, and like the command update-database -script But is there a way of generating the script but have it wrapped with a transaction? Problem is that if the script fails, i have to unpick it This is what I'm using only on release mode to generate the scripts: public class MigrationScriptBuilder : SqlServerMigrationSqlGenerator { #if !DEBUG protected override void Generate(SqlOperation sqlOperation) { Statement("GO"); base.Generate(sqlOperation); Statement("GO"); } public override IEnumerable<MigrationStatement> Generate(IEnumerable

ODP.Net Managed Driver - ORA-12704: character set mismatch in generated code

╄→гoц情女王★ 提交于 2019-11-29 07:24:31
I am currently using the Oracle Managed Driver (v12.1.2400) as my Entity Framework driver, and am currently seeing a ORA-12704: character set mismatch error during execution. The LINQ->SQL code I am using is as follows: from c in CUSTOMER.AsNoTracking() where c.ACCOUNT.Contains("DE") && c.DELETED == "N" orderby (c.FORENAME + c.SURNAME) select new { c.ACCOUNT, c.FORENAME, c.SURNAME}) and this is creating the following SQL: SELECT "Project1"."C2" AS "C1", "Project1"."ACCOUNT" AS "ACCOUNT", "Project1"."FORENAME" AS "FORENAME", "Project1"."SURNAME" AS "SURNAME" FROM ( SELECT( (CASE WHEN ("Extent1"

Many-to-many collection of same entity, with two-way relationship

亡梦爱人 提交于 2019-11-29 07:15:13
Suppose I have a widget entity, and I want to track other widgets that are adjacent to each. If the first widget is adjacent to the second widget, then the inverse is also true—the second is adjacent to the first. Ideally, I would have a single collection on the entity, and could fluently configure the entity for this sort of a relationship. public class Widget { // ... public virtual ICollection<Widget> Adjacent { get; set; } } However, when I try that... modelBuilder.Entity<Widget> .HasMany(w => w.Adjacent) .WithMany(w => w.Adjacent); ...Entity Framework doesn't like it at all. The