entity-framework-6

Mapping composite foreign key to composite primary key where the foreign key is also a primary key

江枫思渺然 提交于 2021-02-07 03:14:53
问题 I want to make VM_hostname,datetime and name properties as a composite Key for Disk class . At the same time VM_hostname and datetime of Disk class should refer to VM_hostname and datetime of VirtualMachine class (ie Foreign keys) . I did this but it gives me this exception : The ForeignKeyAttribute on property 'datetime' on type 'WebJob1.Historical.Disk' is not valid. The navigation property 'Datetime' was not found on the dependent type 'WebJob1.Historical.Disk'. The Name value should be a

Mapping composite foreign key to composite primary key where the foreign key is also a primary key

可紊 提交于 2021-02-07 03:14:06
问题 I want to make VM_hostname,datetime and name properties as a composite Key for Disk class . At the same time VM_hostname and datetime of Disk class should refer to VM_hostname and datetime of VirtualMachine class (ie Foreign keys) . I did this but it gives me this exception : The ForeignKeyAttribute on property 'datetime' on type 'WebJob1.Historical.Disk' is not valid. The navigation property 'Datetime' was not found on the dependent type 'WebJob1.Historical.Disk'. The Name value should be a

How can I query the foreign key objects using Entity Framework?

允我心安 提交于 2021-02-05 06:45:06
问题 I am trying to learn about Entity Framework 6, and I am running into an issue, that I have been able to reproduce in a test project: A Movie has a Name and a Revenue . A Revenue has a GrossIncome : public class Movie { [Key] public int Id { get; set; } public string Name { get; set; } public Revenue Revenue { get; set; } } public class Revenue { [Key] public int Id { get; set; } public double GrossIncome { get; set; } } I am trying to use EF6 code-first to persist some data about movies in

FirebirdSql.Data.FirebirdClient.FbException: too many open handles to database

社会主义新天地 提交于 2021-02-04 07:28:05
问题 Today I did a larger data import into a firebird 2.5.6 database and I got this exception: System.Data.Entity.Core.EntityCommandExecutionException: An error occurred while executing the command definition. See the inner exception for details. ---> FirebirdSql.Data.FirebirdClient.FbException: too many open handles to database ---> FirebirdSql.Data.Common.IscException: too many open handles to database bei FirebirdSql.Data.Client.Managed.Version10.GdsDatabase.ProcessResponse(IResponse response)

Read Oracle SYS_REFCURSOR in C# Entity Framework?

我们两清 提交于 2021-01-29 14:23:30
问题 I have a simple C# console application and its code is like this: using System; using System.Collections.Generic; using System.Data; using System.Data.Common; using System.Linq; using System.Text; using System.Threading.Tasks; using Oracle.ManagedDataAccess.Client; namespace ConsoleApp1 { class Program { static void Main(string[] args) { SHRSContext shrsContext = new SHRSContext(); DbCommand cmd = shrsContext.Database.Connection.CreateCommand(); cmd.CommandText = "PKG_SHRS.GETLOGINATTEMPT";

The entity type 'AspNetUserLogins' requires a primary key to be defined?

蹲街弑〆低调 提交于 2021-01-29 09:04:40
问题 I scaffolded my database with EF and I changed the mydbcontext to inherit from IdentityDbContext because I want everything under one dbcontext . The problem is that when I start the application and write the credentials in the login page, I get an exception: The entity type 'AspNetUserLogins' requires a primary key to be defined which I didn't get before, because I am calling the base.OnModelCreating(modelBuilder); What am I doing wrong? public partial class AdventuresContext :

How do i sort my events with regards to “grandchildren's” date

末鹿安然 提交于 2021-01-29 08:05:22
问题 We’ve got an EF6 MVC3 codeFirst-site. Our Events may have a collection of EventRallies . And the EventRallies may have a collection of EventOccasions I want to order them so that events with any future occasions is at the top, followed by events where all occasions are in the past, and then events that doesn´t have any rallies or occasinons tied to them. The following attempt results in an :System.ArgumentException: DbSortClause expressions must have a type that is order comparable- error ;)

How do I include a [NotMapped] property in an EF business object without getting FirstChance IndexOutofRangeException?

无人久伴 提交于 2021-01-29 06:32:25
问题 I was wondering why my XAF WinForms EF application was slow loading a detail view. Then I learned how to capture FirstChance Exceptions and discovered I was experiencing an IndexOutOfRange exception as described here Sometimes I want to include a non mapped property in my business object such as Job in example. public class OrderLineResult { public int LineId { get; set; } public int Quantity { get; set; } public string Description { get; set; } [Browsable(false)] public int JobId { get; set;

Where to put embedded database file for clickonce deployment

本小妞迷上赌 提交于 2021-01-29 06:12:06
问题 Using a SQLite embedded database. I am using Entity Framework 6. I have the database in the bin folder when I am testing. While testing EF connects fine with the following connection string: public Entities() : base(@"metadata=DataModel1.csdl|DataModel1.ssdl|DataModel1.msl;provider=Devart.Data.SQLite;provider connection string=""Data Source=database.db;FailIfMissing=False""", "Entities") { this.ContextOptions.LazyLoadingEnabled = true; OnContextCreated(); } When I deploy the app using

There is no implicit reference conversion from ApplicationUser to IdentityUser

那年仲夏 提交于 2021-01-29 04:19:18
问题 I am trying to customize some ASP.NET Identity Core classes which use Generics. My ApplicationUser class: public class ApplicationUser : IdentityUser<Guid>//, ApplicationUserClaim, ApplicationRole, ApplicationUserLogin> { public ApplicationUser() { } } My ApplicationUserStore class: public class ApplicationUserStore : UserStore<ApplicationUser, ApplicationRole, ApplicationDbContext, Guid> { public ApplicationUserStore(ApplicationDbContext ctx, IdentityErrorDescriber describer = null) : base