entity-framework-core

How to enable migration in SQLite using EF

允我心安 提交于 2019-12-04 19:58:55
问题 I have stuck in problem. I am writing a code for windows desktop application and I have to use sqlite as a database. I have successfully installed system.data.sqlite and entity framework from nuget package. I have also created my DbContext class. Now problem is that as soon as I tried to run my code an exception comes whose inner message is {"SQLite Error 1: 'no such table: TimeSheet'"}. This means your table TimeSheet does not exist in database. Plz tell me how to create table in sqlite

'System.ValueTuple, Version=0.0.0.0 required for Add-Migration on .NET 4.6.1 Class Library

天涯浪子 提交于 2019-12-04 19:06:08
问题 I upgraded a .net standard class library from Entity Framework Core 1.1 to Entity Framework 2.0 I am trying to run Add-Migration on an Entity Framework Core Class Library that targets .net framework 4.6.1 Add-Migration MyMigration But I then get the following error System.IO.FileLoadException: Could not load file or assembly 'System.ValueTuple, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not

SQLite Data Provider is missing in Visual Studio 2017

荒凉一梦 提交于 2019-12-04 18:23:28
问题 Using Nuget Package Manager I installed System.Data.SQLite (x86/x64) in VS2017 . That resulted in installing the following packages as well: System.Data.SQLite System.Data.SQLite.EF6 System.Data.SQLite.Core But as shown in image below, the Add New Data Source dialog box does not show the SQLite Data Provider : 回答1: The NuGet package is for your project and does not include a provider. For that, you need to install a DDEX provider package. There doesn't seem to be an official SQLite DDEX

Entity Framwork 7 reverse engineer from existing db “code first”

寵の児 提交于 2019-12-04 16:59:57
I can't figure out how to pass the connection string parameter in the latest version of dnx... trying dnx ef dbcontext scaffold -connection='sql connection string' but it doesn't recognize the -connection parameter .. how are you supposed to pass arguments into the thing? Have you tried: dnx ef dbcontext scaffold "sql connection string" EntityFramework.MicrosoftSqlServer 来源: https://stackoverflow.com/questions/32377984/entity-framwork-7-reverse-engineer-from-existing-db-code-first

How do I delete multiple rows in Entity Framework Core?

纵饮孤独 提交于 2019-12-04 16:29:11
问题 I need to delete multiple rows from a database using Entity Framework Core. This code does NOT work: foreach (var item in items) { myCollection.Remove(item); } because I get an error "InvalidOperationException: Collection was modified; enumeration operation may not execute" after the first object. In other words, .Remove removes only one object. Entity Framework Core does NOT have .RemoveRange , so I have no idea how to perform this operation. In order to preserve maximum compatibility with

Visual Studio Code Entity Framework Core Add-Migration not recognized

无人久伴 提交于 2019-12-04 16:06:51
问题 I've used yoman to generate an ASP.Net Core Web API application via the Visual Studio Code Editor. For reference, I followed this tutorial here The API works fine. However, I am trying to use Entity Framework Core Migrations with SQL Server. When I type the following into the Visual Studio Code Terminal: Add-Migration MyDbInitialMigration I get the following message: 'Add-Migration' is not recognized as an internal or external command, operable program or batch file. I have the Microsoft

How to use EF Core (EF7) with Mysql server?

大城市里の小女人 提交于 2019-12-04 15:49:54
问题 I am developing asp.net 5 (now called ASP.NET Core) on linux. But I cannot connect between EF7 (now called EF Core) and Mysql server. Please tell me any solution that you knew. Thanks. 回答1: All available providers are listed at https://docs.microsoft.com/en-us/ef/core/providers/. At time of writing, there are 3 different EF Core providers, two community versions and one official version. UPDATE Sept 15, 2016 MySQL released the first version of an official provider for EF Core. https://www

Disable cascade delete on EF Core 2 globally

时间秒杀一切 提交于 2019-12-04 15:45:04
问题 I need to know about ways of disabling cascade delete in EF Core 2 globally. Any help is appricated. In EF 6.x we used following code to disable cascade delete on both OneToMany and ManyToMany realtions: builder.Conventions.Remove<OneToManyCascadeDeleteConvention>(); builder.Conventions.Remove<ManyToManyCascadeDeleteConvention>(); 回答1: Unfortunately EF Core currently (latest at this time v2.0) does not expose a good way to control the conventions globally. The default EF Core 2.0 convention

How to run dynamic SQL query in Entity Framework 7 that auto-maps to Entities (SqlQuery<T>)?

邮差的信 提交于 2019-12-04 15:27:57
I have an existing app that I am trying to upgrade from MVC5/EF6 to MVC6/EF7. We dynamically create some of our SQL tables, and as a result, have made use of the System.Data.Entity.Database.SqlQuery method to automatically map to entities that we use throughout our application. This method seems to have gone away (i.e. not part of Microsoft.Data.Entity.Infrastructure.Database ) in EF7 (or is not yet implemented). Are there plans to re-implement this method in EF7 or is there another way to accomplish this? Our project is kind of dead in the water until we figure this out. Edited on May 20,

How to call stored procedure with table valued parameter from .net core Entity Framework

落花浮王杯 提交于 2019-12-04 15:26:23
I have a stored procedure with table valued parameter. I have to call it from Entity framework in .net core. I couldn't find any API on context object. I have tried with ADO.net API's and it worked but now I have to call it from EF in .net core. Stored procedure which I have to call returning result which I have to catch. My sample SP as below CREATE PROCEDURE [dbo].[GetMyData] @MyRequest [dbo].[MyRequestType] Readonly As BEGIN --Its sample SP thats why returned request table as it is select * from @MyRequest END MyRequestType is User defined table type its structure is as below CREATE TYPE