entity-framework

asp.net core 2.0 bind model with decimal value

旧街凉风 提交于 2020-12-05 11:13:46
问题 I've been looking for a solution to this case for hours, and I did not find anything that worked out for me. Here we use the comma for decimal separator, and when I send a value like "15,50", in my controller I get the value of the model as "1550", and it only makes sense if I send "15.50". I covered the following topics, and nothing worked. Set CultureInfo in Asp.net Core to have a . as CurrencyDecimalSeparator instead of , Aspnet Core Decimal binding not working on non English Culture I am

Hibernate: foreign key without entity class, only by id

核能气质少年 提交于 2020-12-05 05:14:13
问题 I have a hierarchical entity, which references it self as a parent. I need to do the mapping only via ids, not via entity instances (the reason is too complicated to explain). So I defined the entity this way: class Item { @Id private String id; @ManyToOne(targetEntity = Item.class) @JoinColumn(name = "PARENT_ID", nullable = true) private String parentId; } This seems to work fine. The foreign key constraint is created correctly in database. But when I execute the following query: SELECT i

Hibernate: foreign key without entity class, only by id

元气小坏坏 提交于 2020-12-05 05:13:48
问题 I have a hierarchical entity, which references it self as a parent. I need to do the mapping only via ids, not via entity instances (the reason is too complicated to explain). So I defined the entity this way: class Item { @Id private String id; @ManyToOne(targetEntity = Item.class) @JoinColumn(name = "PARENT_ID", nullable = true) private String parentId; } This seems to work fine. The foreign key constraint is created correctly in database. But when I execute the following query: SELECT i

Hibernate: foreign key without entity class, only by id

孤街醉人 提交于 2020-12-05 05:13:35
问题 I have a hierarchical entity, which references it self as a parent. I need to do the mapping only via ids, not via entity instances (the reason is too complicated to explain). So I defined the entity this way: class Item { @Id private String id; @ManyToOne(targetEntity = Item.class) @JoinColumn(name = "PARENT_ID", nullable = true) private String parentId; } This seems to work fine. The foreign key constraint is created correctly in database. But when I execute the following query: SELECT i

Can I use Entity Framework 6 (not core) in .net core?

北慕城南 提交于 2020-12-01 02:07:48
问题 Entity Framework Core does not support spatial data, which I need to use in my app. Can I use Entity Framework 6 in .net core? If so, how can I register DatabaseContext in Startup.cs ? 回答1: No, you can not directly, because EF6 doesn't support .NET Core. But, you can create another project, that compiles against full .NET framework and use it as a reference. MS has actually made a decent tutorial for this: https://docs.microsoft.com/en-us/aspnet/core/data/entity-framework-6#reference-full

C# Entity Framework: Linq Filter out certain GrandChild Elements

放肆的年华 提交于 2020-11-30 01:56:31
问题 How do I filter out Grandchild elements with a Linq EF Query? This Customer has multiple transactions, and only need subchild elements with Certain ProductTypeId. Its currently bringing All ProductType Ids ignoring the filter . var result = db.Customer .Include(b => b.Transactions) .Where(a => a.Transactions.Select(c=> c.ProductTypeId== productTypeId).Any()) Sql query, that I want: select distinct c.customerName from dbo.customer customer inner join dbo.Transactions transaction on transaction

Load child entity on the fetch of the Parent entity EFCore

筅森魡賤 提交于 2020-11-29 09:39:11
问题 I have the below model. What is the better way to load the parent entity with child entity at the time of fetching from the DB with find method? Parent Entity: public class Client { public int Id { get; set; } public string LastName { get; set; } public string Gender { get; set; } public DateTime DateOfBirth { get; set; } public Address Address { get; set; } } Child Entity: public class Address { public int Id { get; set; } public string FirstLine { get; set; } public string SecondLine { get;

How to fix 'Unable to determine the relationship represented by navigation property' error in Entity Framework

a 夏天 提交于 2020-11-28 08:56:43
问题 When I try to register a user on my .NET Core 2.1 website (using identity) I get the following error: "InvalidOperationException: Unable to determine the relationship represented by navigation property 'City.ConnectionStartCity' of type 'ICollection'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.". The reason this happens probably has nothing to do with identity, but

How to fix 'Unable to determine the relationship represented by navigation property' error in Entity Framework

非 Y 不嫁゛ 提交于 2020-11-28 08:52:24
问题 When I try to register a user on my .NET Core 2.1 website (using identity) I get the following error: "InvalidOperationException: Unable to determine the relationship represented by navigation property 'City.ConnectionStartCity' of type 'ICollection'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.". The reason this happens probably has nothing to do with identity, but

How to fix 'Unable to determine the relationship represented by navigation property' error in Entity Framework

匆匆过客 提交于 2020-11-28 08:52:13
问题 When I try to register a user on my .NET Core 2.1 website (using identity) I get the following error: "InvalidOperationException: Unable to determine the relationship represented by navigation property 'City.ConnectionStartCity' of type 'ICollection'. Either manually configure the relationship, or ignore this property using the '[NotMapped]' attribute or by using 'EntityTypeBuilder.Ignore' in 'OnModelCreating'.". The reason this happens probably has nothing to do with identity, but