entity-framework

One to one mapping in EF Code First and bi-directional navigation properties

≯℡__Kan透↙ 提交于 2021-02-19 08:26:37
问题 I have been tasked with porting an old app to MVC 3, and want to use EF's code first to replicate its existing database schema. The current code base is littered with hard coded SQL commands, and so the model I come up with has to be "compatible" with what the current system expects. I know I could use EF's Database First to do this, but the existing schema is so simple that I see no reason not to use code first, as I want a solid foundation to build on as we migrate away from our old hard

Entity Framework metadata artifact not embeded when using xbuild and mono

拈花ヽ惹草 提交于 2021-02-19 07:36:40
问题 When I try and use EntityFramework and MySQL on a Linux or Windows environment I run into the following problem: Project 1: Contains EntityFramework edmx and logic to insert update data using the dbcontext class Project 2: References Project 1. When I build the solution using msbuild the EntityFramework metadata files are embeded in Project1.dll When I do a clean build with xbuild in a Linux environment or in a Windows environment the EntityFramework metadata files are missing When you run

Entity Framework metadata artifact not embeded when using xbuild and mono

☆樱花仙子☆ 提交于 2021-02-19 07:36:25
问题 When I try and use EntityFramework and MySQL on a Linux or Windows environment I run into the following problem: Project 1: Contains EntityFramework edmx and logic to insert update data using the dbcontext class Project 2: References Project 1. When I build the solution using msbuild the EntityFramework metadata files are embeded in Project1.dll When I do a clean build with xbuild in a Linux environment or in a Windows environment the EntityFramework metadata files are missing When you run

EF Migrations drops index when adding compsite index

偶尔善良 提交于 2021-02-19 07:01:50
问题 I noticed EF removed an index on a foreign key when I added a composite index with the foreign key. So I need to understand composite indexes better :) I added the composite index using this answer and generated my EF code first migration file. Adding composite index: this.Property(x => x.Name) .HasUniqueIndexAnnotation("IX_UniqueNamePerKey", 0); this.Property(x => x.TeacherId) .HasUniqueIndexAnnotation("IX_UniqueNamePerKey", 1); Migration file: public partial class CompositeIndex :

ef core 2.0 scaffold-dbcontext custom namespace

馋奶兔 提交于 2021-02-19 06:46:06
问题 I am using the ef core 2.0 CLI command scaffold-dbcontext to reverse engineer poco classes from an existing DB (database first). I want to put the generated classes from scaffold-dbcontext in a "Model" folder within my project but I want the namespace of the classes to be something different than "MyProjectName.Model". For example, I want the scaffold-dbcontext generated files to live in the Model folder but I want the namespace of the genereated files to be "MyProjectName.Entities". Is there

EF Code First Project Doesn't Create AspNetUsers, AspNetRoles etc Tables after changing DB Connection

感情迁移 提交于 2021-02-19 02:47:06
问题 I've finished an EF Code First Project with a SQL Express database in a lab environment. Once the project is done, I've changed the DB Connection String to connect to the new Production SQL Express Database. Now, I have got the Model tables generated automatically but the AspNetUsers, AspNetRoles, AspNetUserRoles etc. are not generated automatically. I am a new learner and I need your help to know how I can get the tables back in the database. If I do update-database from the Package Manager

Forcing Entity Framework to not generate NCLOB's when building Linq-to-Sql Code (Model First)

不羁的心 提交于 2021-02-19 00:36:01
问题 I have a class with a nullable int property that that for filtering reasons, I need to convert to a string to do some comparisons. I have EF 6.1.2 installed, so using a .ToString() will work for that. queryableData = queryableData.Where(a => a.PropName.HasValue && a.PropName.Value.ToString().Contains("8675309")); When examining the actual SQL being executed, the number is being CAST into an NCLOB type, which is resulting in the following error: ORA-00932: inconsistent datatypes: expected

Forcing Entity Framework to not generate NCLOB's when building Linq-to-Sql Code (Model First)

南楼画角 提交于 2021-02-19 00:34:36
问题 I have a class with a nullable int property that that for filtering reasons, I need to convert to a string to do some comparisons. I have EF 6.1.2 installed, so using a .ToString() will work for that. queryableData = queryableData.Where(a => a.PropName.HasValue && a.PropName.Value.ToString().Contains("8675309")); When examining the actual SQL being executed, the number is being CAST into an NCLOB type, which is resulting in the following error: ORA-00932: inconsistent datatypes: expected

Forcing Entity Framework to not generate NCLOB's when building Linq-to-Sql Code (Model First)

 ̄綄美尐妖づ 提交于 2021-02-19 00:34:11
问题 I have a class with a nullable int property that that for filtering reasons, I need to convert to a string to do some comparisons. I have EF 6.1.2 installed, so using a .ToString() will work for that. queryableData = queryableData.Where(a => a.PropName.HasValue && a.PropName.Value.ToString().Contains("8675309")); When examining the actual SQL being executed, the number is being CAST into an NCLOB type, which is resulting in the following error: ORA-00932: inconsistent datatypes: expected

Can't Add ADO.NET Entity Data Model to .NET Core 2.1 Project

孤街醉人 提交于 2021-02-18 20:13:43
问题 The Issue... As the title states, I've installed the .NET Core 2.1 SDK and created a new .NET Core 2.1 project. When I go to Project > Add Item... > Data , I do not have the ADO.NET Entity Data Model option. I am using Visual Studio 2017 15.7.3 , which I've installed only hours ago. The Error and Warning logs are clean. Any assistance is appreciated. What I've done so far... Researched. You'll notice I've pulled most of my attempts to solve this issue from primarily these three resources: