entity-framework-4

Entity Framework 4 - Mapping non-public properties with CTP5 (code first) in a persistence unaware context

南笙酒味 提交于 2019-12-21 03:46:12
问题 I know the question already has a solution (eg. this question) but I really can't afford to attach the mapping logic in the same assembly where the domain (POCO classes) is. Is there any other way? I found this nice blog post but I couldn't get it working. Here is the model: public class Institute { /** Code omitted **/ protected virtual ICollection<InstituteText> InnerInstituteTexts { get; set; } private InstituteTextSet _TextSets; public InstituteTextSet Texts { get { if (_TextSets == null)

Entity Framework 4 - Mapping non-public properties with CTP5 (code first) in a persistence unaware context

烂漫一生 提交于 2019-12-21 03:46:03
问题 I know the question already has a solution (eg. this question) but I really can't afford to attach the mapping logic in the same assembly where the domain (POCO classes) is. Is there any other way? I found this nice blog post but I couldn't get it working. Here is the model: public class Institute { /** Code omitted **/ protected virtual ICollection<InstituteText> InnerInstituteTexts { get; set; } private InstituteTextSet _TextSets; public InstituteTextSet Texts { get { if (_TextSets == null)

How do I retrieve and set user_version in SQLite DB with EF

眉间皱痕 提交于 2019-12-21 03:43:28
问题 What I am trying to do is load in and set the user_version (PRAGMA user_version) from my SQLite database. I am using entity framework, but if I can't do it through that, then I need to be able to do it some other way possible within C# 4.0. I tried: this.DatabaseConnection.Connection.Open(); System.Data.Common.DbCommand cmd = this.DatabaseConnection.Connection.CreateCommand(); cmd.CommandText = "PRAGMA user_version"; cmd.CommandType = System.Data.CommandType.Text; System.Data.Common

Using Entity Framework with historical data

老子叫甜甜 提交于 2019-12-21 03:42:54
问题 I'm building a windows application in .Net 4.0 to create and organize electronics projects. The main purpose of the application is to record the vendor information for the electronics components (part #, description, price, etc.) and organize (associate) them into projects (finished products). One of the requirements is to track changes for any given vendor item (mainly price) and changes at the project level to provide a point-in-time statistics at both component level and project level

Entity Framework Database First regeneration make me lose manual changes

寵の児 提交于 2019-12-21 03:13:48
问题 I'm making a website with MVC .NET. Since I'm an old school programmer who learn to design database first, I opted for the Database first approach. I'm also using "code generation" which create files with the extension .tt . Everything is working so far except one things that botters me. Classic scenario: I realise that I am missing one field I add the field in the database. I go into the edmx and choose to update the model from the database. Then I go back to my code and things that use to

EF4 Code First, TDD, CRUD, and Transactions

故事扮演 提交于 2019-12-21 02:56:25
问题 In the past, I've written unit tests for simple CRUD operations when creating data access/repository code that look something like this: using(var connection = new WhateverConnection(connectionString)) { connection.Open(); using(var transaction = connection.BeginTransaction()) { try { //test the CRUD operation } finally { //gets rid of any stuff created during the test transaction.Rollback(); } } } I was messing around with EF4 Code First today, and I realized that I have no idea how this

Entity framework very slow to load for first time

妖精的绣舞 提交于 2019-12-21 02:42:21
问题 I'm using EF 4 on my web site and have found a very disturbing problem - the first run load time is extremely slow. (about 20-30 seconds). After the first run - it will work really fast. What I mean by "first run" is a run after some long time of no activity (10 minutes or so). So, if there is a lot of traffic, the site is working just fine. If there are slow days - the first one to come to the site after a long traffic break, will get a very bad experience. Because the web site also exposes

Using database generated GUID and datetime with EF4

徘徊边缘 提交于 2019-12-20 23:03:13
问题 I have a simple table with an ID (a uniqueidentifier ), a datetime , and a value. I'd like to use getdate() on the database for the record insertion time and newid() for the id. How do I configure entity framework to do this? When I try to assign the id on the DB I get: Violation of PRIMARY KEY constraint 'PK_Random'. Cannot insert duplicate key in object 'dbo.Random'. The duplicate key value is (00000000-0000-0000-0000-000000000000). 回答1: if you are using code first. Please add the following

Recommend usage of temp table or table variable in Entity Framework 4. Update Performance Entity framework

牧云@^-^@ 提交于 2019-12-20 18:43:11
问题 I need to update a bit field in a table and set this field to true for a specific list of Ids in that table. The Ids are passed in from an external process. I guess in pure SQL the most efficient way would be to create a temp table and populate it with the Ids, then join the main table with this and set the bit field accordingly. I could create a SPROC to take the Ids but there could be 200 - 300,000 rows involved that need this flag set so its probably not the most efficient way. Using the

Is SQL Azure suitable for Desktop client applications

删除回忆录丶 提交于 2019-12-20 18:30:38
问题 I have a client that runs a small business. They need a custom database solution and I'm looking into various options. My experience is limited to .NET using local SQL Servers (no ASP.NET), however, this client is non-technical and would benefit from being able to outsource the DBA tasks. I'm a complete Azure noob, I just scanned the tutorials and they all appear targeted at developing MVC ASP solutions. The client doesn't need a browser based solution. A fat desktop client used from