entity-framework

One to many recursive relationship with Code First

萝らか妹 提交于 2021-01-27 04:23:13
问题 I am trying to implement a simple self referencing relationship with EF 6.1.2 Code First. public class Branch { [Key] public int Id { get; set; } [Required] public string Name { get; set; } public int? ParentId { get; set; } [ForeignKey("ParentId")] public virtual Branch Parent { get; set; } public ICollection<Branch> Children { get; set; } // direct successors } In my application I have exactly one root branch. And except for this single root branch, every branch has exactly one parent (the

How to register Firebird data provider for Entity Framework?

那年仲夏 提交于 2021-01-27 04:11:38
问题 How do I register a Firebird data provider to use it with Entity Framework? What should I do to make it appear in the Entity Data Model Wizard/Choose Data Source window? I expect it to appear in the Data sources: or Data provider: lists. Is it possible? Or I need to configure this connection another way? PS: The provider I'm trying to use is the FirebirdClient 2.5 回答1: You have to install DDEX Provider for Visual Studio http://www.firebirdsql.org/index.php?op=files&id=netprovider http://web

How to register Firebird data provider for Entity Framework?

为君一笑 提交于 2021-01-27 04:11:02
问题 How do I register a Firebird data provider to use it with Entity Framework? What should I do to make it appear in the Entity Data Model Wizard/Choose Data Source window? I expect it to appear in the Data sources: or Data provider: lists. Is it possible? Or I need to configure this connection another way? PS: The provider I'm trying to use is the FirebirdClient 2.5 回答1: You have to install DDEX Provider for Visual Studio http://www.firebirdsql.org/index.php?op=files&id=netprovider http://web

EF6 codefirst + MySql migrations: type nvarchar(max) not supported

人走茶凉 提交于 2021-01-27 04:01:52
问题 I'm trying to use EF6 code first + MySql with migrations, but I'm stuck with this error during add-migration : The underlying provider does not support the type 'nvarchar(max)' It thus seems EF is trying to use SQLServer types for MySql, even if I have changed the default connection factory in my config. I can find a lot of issues with the same error message but none of them seems up to date or to suggest something I did not already try. Here are my steps for enabling migrations in a DAL dll

EF6 codefirst + MySql migrations: type nvarchar(max) not supported

时光怂恿深爱的人放手 提交于 2021-01-27 04:01:04
问题 I'm trying to use EF6 code first + MySql with migrations, but I'm stuck with this error during add-migration : The underlying provider does not support the type 'nvarchar(max)' It thus seems EF is trying to use SQLServer types for MySql, even if I have changed the default connection factory in my config. I can find a lot of issues with the same error message but none of them seems up to date or to suggest something I did not already try. Here are my steps for enabling migrations in a DAL dll

Calling Oracle stored procedure using Entity Framework with output parameter?

倖福魔咒の 提交于 2021-01-27 03:00:08
问题 I have a simple Oracle stored procedure that gets three parameters passed in, and has one output parameter: CREATE OR REPLACE PROCEDURE RA.RA_REGISTERASSET ( INPROJECTNAME IN VARCHAR2 ,INCOUNTRYCODE IN VARCHAR2 ,INLOCATION IN VARCHAR2 ,OUTASSETREGISTERED OUT VARCHAR2 ) AS BEGIN SELECT INPROJECTNAME || ', ' || INLOCATION || ', ' || INCOUNTRYCODE INTO OUTASSETREGISTERED FROM DUAL; END RA_REGISTERASSET; I am trying to use Entity Framework 6.1 to get back the OutAssetRegistered value, however, I

Using only the year part of a date for a WHERE condition

冷暖自知 提交于 2021-01-26 20:34:48
问题 In the LINQ statement below, I want to select people with an exam date in 2010. The exam date is stored as a datetime as the actual date and time is used in other applications. What is the most elegant, easiest, best way to compare the exzam date to only '2010'. Or, should I just compare, using >=, the exam date to 1/1/2010? var active = dc.People.Where(x => x.exam >= 2010) .Select(x => new {x.ContactID, x.FirstName, x.LastName}) ); x.MostRecent == DateTime.Parse("1/1/2010").Year EDIT #1 I

Using only the year part of a date for a WHERE condition

ε祈祈猫儿з 提交于 2021-01-26 20:34:41
问题 In the LINQ statement below, I want to select people with an exam date in 2010. The exam date is stored as a datetime as the actual date and time is used in other applications. What is the most elegant, easiest, best way to compare the exzam date to only '2010'. Or, should I just compare, using >=, the exam date to 1/1/2010? var active = dc.People.Where(x => x.exam >= 2010) .Select(x => new {x.ContactID, x.FirstName, x.LastName}) ); x.MostRecent == DateTime.Parse("1/1/2010").Year EDIT #1 I

PlatformNotSupportedException: Microsoft.Data.SqlClient is not supported on this platform

三世轮回 提交于 2021-01-24 13:50:06
问题 What might be the error? I looked at similar problems, downgrading the version to 2.0 is workaround but this is not true DAL.dll <ItemGroup> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="3.1.4" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.4" /> </ItemGroup> UIWEBAPP.dll <ItemGroup> <PackageReference Include="CKEditor" Version="3.6.4" />

Entity Framework, Saving a Collection of Enums

主宰稳场 提交于 2021-01-24 09:35:14
问题 I have a table to save phone numbers for a contact. Within the table I have phone restrictions to tie to each phone number. The phone restrictions are stored as enums, but they can have multiple phone restrictions. When I try and create a migration I get the error The property 'PhoneNumber.Restrictions' could not be mapped, because it is of type 'ICollection' which is not a supported primitive type or a valid entity type. Either explicitly map this property, or ignore it using the '[NotMapped