entity-framework-core

Can Entity Framework Core code migrations work reliably and practically against different database types

冷暖自知 提交于 2019-12-13 07:17:40
问题 I would like to clarify that this is the Core version Entity Framework that I'm working with. I think I know the answer, but it's all based on assumptions from other ORMs I used years ago. My guess is the answer is something like "it depends based on the specific database(s) and the features used (keys, constraints, etc)". Additionally, I want to clarify that I'm not asking if migrations can be generated from the model for different DBs. I know the answer is yes to that. I'm asking about a

ASP.NET 5, EF 7 and SQLite - compiler error CS1061

对着背影说爱祢 提交于 2019-12-13 07:16:05
问题 I have a ASP.NET 5 project in VS 2015 (Beta 8) that includes EF 7 which is working on Full-CLR but not Core-CLR. Below is the partial configuration: "dependencies": { "EntityFramework.Commands": "7.0.0-beta8", "EntityFramework.SQLite": "7.0.0-beta8", "EntityFramework.SQLite.Design": "7.0.0-beta8" } services.AddEntityFramework() .AddSqlite(); When using the above and publishing to Docker I get the following error: DNX,Version=v4.5.1 error CS1061: 'EntityFrameworkServicesBuilder' does not

asp.net core creating/updating a foreignkey

守給你的承諾、 提交于 2019-12-13 06:38:29
问题 I added to my "Todo" class a foreignKey to my "Pharmacy" class. When I add or edit a Todo, no Pharmacy can be linked (from a selectbox). Here's my model: public class Todo { [Key] public int ID { get; set; } public Pharmacy Pharmacy { get; set; } } public class Pharmacy { [Key] public int PharmacyID { get; set; } public string Name { get; set; } public string Pharmacist { get; set; } [DataType(DataType.PhoneNumber)] public int Phone { get; set; } [DataType(DataType.EmailAddress)] public

Entity Framework 7 Beta7 has no ColumnType anymore

你说的曾经没有我的故事 提交于 2019-12-13 06:08:46
问题 This code does not compile as the ColumnType method is unknown in EF7 Beta7 . What is the new method to determine a special column type? modelBuilder.Entity<Language>() .Property(a => a.ISO639_ISO3166) .ColumnType("char") .MaxLength(5) .Required(); 回答1: To change the column type you need to use the HasColumnType method: modelBuilder.Entity<Language>() .Property(a => a.ISO639_ISO3166) .HasColumnType("char") .MaxLength(5) .Required(); And if you are targeting more than one relational provider

Get “502 - Web server received an invalid response while acting as a gateway or proxy server” error when opening register page on Azure

孤者浪人 提交于 2019-12-13 05:26:56
问题 I have been playing around with Azure and am looking to publish my .net core 2 application there. So far, this builds on my local machine fine. I can register as a user, so I know everything is okay, locally. I can see users and have even managed to register certain users with certain claims. I can publish the site to azure: https://mytrade20180517093224.azurewebsites.net/ I can also log into the azure database from vs2017 using the same credentials I supplied in my appsettings.json. However,

How to cope with “No data stores are configured”?

半腔热情 提交于 2019-12-13 04:32:19
问题 I am currently playing with beta4 of EF7 using the blank ASP.NET web project template. After having kicked off the existing migration, resulting in the tables being created in the localdb, the following occurs: Strangely, when I clean up the migration-folder, including removing ApplicationDbContextModelSnapshot.cs and I run dnx . ef migration add twice, I get the following error: dnx : System.InvalidOperationException: No data stores are configured. Configure a data store by overriding

AutoMapper ProjectTo() configuration question

落爺英雄遲暮 提交于 2019-12-13 04:29:57
问题 Not able to map one of the Dto's: ViewModel: public class TicketViewModel { public TicketDto Ticket { get; set; } public CompanyDto Company { get; set; } public TicketStateDto TicketState { get; set; } public string TicketPriorityName { get; set; } } Company and TicketState are navigation properties. Query: var query = _ticketRepository.GetAll() // return IQueryable<Ticket> .Include(c=> c.Company) .Include(tt => tt.TicketState) .Include(ts => ts.TicketPriority) .OrderBy(n => n.Id) .ProjectTo

How to avoid aggregate being dependent on outside includes?

帅比萌擦擦* 提交于 2019-12-13 04:17:49
问题 I do not use lazy loading. My root aggregate have entities (collection navigation properties). I want my aggregate to be self-contained, responsible for itself, and follow the Single Responsibility Principle (SRP), and adhere to high cohesion and low coupling. The problem is that the code that retrieves the root aggregate needs to include certain child entities depending on which way it wants to interact with the aggregate. Example: public class Blog // My root aggregate { public ICollection

Error when Razor page opens and have a related drop down list

不羁的心 提交于 2019-12-13 04:12:04
问题 I'm attempting to create a form (Books) with a simple drop down list displaying fields from a related table (Authors). Book Model: namespace SimpleDropDownList.Models { public class Book { [Key] public int BookID { get; set; } [StringLength(255)] [Display(Name = "Book Title")] public string Title { get; set; } public int AuthorID { get; set; } public Author Author { get; set; } public AuthorViewModel AuthorViewModel { get; set; } } } Author Model: namespace SimpleDropDownList.Models { public

EF Core - How to setup many-to-many for same entity that already has a one-to-many relationship

佐手、 提交于 2019-12-13 04:08:05
问题 I currently have a one-to-many relationship between a Post and Comment . One Post can contain multiple Comments . What I want to do is create a many-to-many relationship for Comments. I also have a one-to-many relationship between User and Comment . I.e. each Comment should be able to contain a collection of Comment . E.g. a user can comment on another user's comment. I want to preserve the ordering of comments so that I can display them in the correct order. public class Comment { [Key]