entity-framework-6

Entity Framework 6 Code First on SQL Server: Map “bool” to “numeric(1,0)” instead of “bit”

此生再无相见时 提交于 2020-01-15 10:25:08
问题 Forward warning #0: upgrading to EF core is not an option in the near future. Forward warning #1: I can't change the column type to bit because this could potentially break legacy VB apps that employ the very same db I'm developing a new app for. Forward warning #2: I also can't employ the int property ==> hidden bool property approach because the very same model needs to work when targeting an Oracle database (in Oracle decimal(1,0) does indeed get mapped to bool without issues - I need to

Asynchronous EF query in F#

谁说我不能喝 提交于 2020-01-15 08:44:10
问题 In C# using EF6 I can easily make asynchronous operations like this: using (var context = new MyDbContext()) { var item = await context.SomeEntities.Where(e => e.Id == 1).FirstAsync(); DoSomething(item); } How could I do the same with F# async workflow? I am aware of query workflow and how to use it instead of LINQ, but I have no idea how to make it properly async (i.e. without permanent consumption of thread pool, like in a C# example). Here's what I got so far (it is synchronous): use

Setting a default object for Entity Framework navigation property

a 夏天 提交于 2020-01-15 08:24:14
问题 Is it possible to set a default object for an Entity? Say I have a Person entity that originally did not have a requirement for a Profile . Now I require a Profile - but there are existing entities that do not currently have a Profile . Is there a way I can provide a default object for these Entities when they're loaded in future, so anyone using the Person Entity can assume that Profile is never null and always has a value - even if it's a default. Below you can see what I've tried - which

Update entity with ViewModel and Entity Framework 6?

半世苍凉 提交于 2020-01-15 05:40:12
问题 I've been looking around and can't quite find the answer. I'm using a ViewModel in my Edit View so that I can have values for some dropdownlist. Now when I go to update my DB I'm not understanding how I can update my database record. I'm guessing I could create a new entity object, do a Find, and then update each property based on the ViewModel passed in from the Form but that sure seems like a lot of manual work. Here I'm using the VeiwModel in the Edit View. @model CPPCustomerCall

Update entity with ViewModel and Entity Framework 6?

北城以北 提交于 2020-01-15 05:40:09
问题 I've been looking around and can't quite find the answer. I'm using a ViewModel in my Edit View so that I can have values for some dropdownlist. Now when I go to update my DB I'm not understanding how I can update my database record. I'm guessing I could create a new entity object, do a Find, and then update each property based on the ViewModel passed in from the Form but that sure seems like a lot of manual work. Here I'm using the VeiwModel in the Edit View. @model CPPCustomerCall

Entity Framework not Saving Changes into Database

南楼画角 提交于 2020-01-14 12:20:10
问题 I'm puzzled as to why this code is not working, it should save changes to database after the loops but when I place the SaveChanges method inside the loop, it saves the record into the database but outside it doesn't save anything? it's about only 300 ~ 1000 records static bool lisReady = false; static bool sacclReady = false; static void Main(string[] args) { Logger("Starting services"); ConnectDBLis().Wait(); ConnectDBSaccl().Wait(); Thread.Sleep(1000); if (lisReady & sacclReady){ //start

Entity Framework not Saving Changes into Database

陌路散爱 提交于 2020-01-14 12:17:04
问题 I'm puzzled as to why this code is not working, it should save changes to database after the loops but when I place the SaveChanges method inside the loop, it saves the record into the database but outside it doesn't save anything? it's about only 300 ~ 1000 records static bool lisReady = false; static bool sacclReady = false; static void Main(string[] args) { Logger("Starting services"); ConnectDBLis().Wait(); ConnectDBSaccl().Wait(); Thread.Sleep(1000); if (lisReady & sacclReady){ //start

How to exclude some column from .edmx file, *.csdl ,*.msdl, and *.ssdl dynamically using Database first Approach

懵懂的女人 提交于 2020-01-14 02:29:08
问题 what i am trying to do is exclude few column from EF store and EF modal. for reference there are two method : https://stackoverflow.com/a/40742144/4998968 but i want to exclude column when edmx file is created i.e when i connect my database using Ado.net Data modal option i want few columns to be excluded from edmx as if they don't exists in database. currently i am exploring the entity framework source code but cannot find the exact code that generates .edmx file and store. example: suppose

Is there a better/cleaner way to find Independent Association changes (adds/removes) than this?

女生的网名这么多〃 提交于 2020-01-13 19:10:40
问题 I found this answer which (unless I'm missing something) gives a good solution to catch all changes made to all independent associations in a DbContext. I am trying to adapt that solution to something more specific, to create a function that can find the changes for a particular navigation property on a particular entity. The goal is for the user of this function to not have to worry about any of the internals of EntityFramework, and to only be concerned with his POCO models. This is what I

Entity Framework Seeding with Identity (Microsoft.Owin.Security) user

房东的猫 提交于 2020-01-13 10:30:08
问题 I have a class that seed the database which add 2 users with roles and custom fields. The problem I have is that it save the data in [dbo].[AspNetUsers] instead of [dbo].[IdentityUsers]. Both tables are created. When seeded, the data go into AspNetUser. When I launch the web site, and register a new user, the data go into IdentityUser. Here is the Migration class : internal sealed class Configuration : DbMigrationsConfiguration<DatabaseContext> { public Configuration() {