entity-framework-4

EntityFramework ConnectionString utf8

青春壹個敷衍的年華 提交于 2019-12-10 18:56:25
问题 I want to add utf8 support to my Entity Framework database application (sql server 2008 r2) I think I need to add the charset to the connectionString. This is how my connectionString works (anonymized, of course) <add name="MyContainer" connectionString="metadata=res://*/MyDatabase.csdl|res://*/MyDatabase.ssdl|res://*/MyDatabase.msl;provider=System.Data.SqlClient;provider connection string="Data Source=myserver\instancename;Initial Catalog=MyCatalog;Persist Security Info=True;User ID=USERNAME

What does “Entity Tracked by Context” mean in Entity Framework

不想你离开。 提交于 2019-12-10 18:45:19
问题 I am reading this E.F. Team Blog's this series http://blogs.msdn.com/b/adonet/archive/2011/01/27/using-dbcontext-in-ef-feature-ctp5-part-1-introduction-and-model.aspx At many places i saw this term "Entity Tracked by Context", specially in this part http://blogs.msdn.com/b/adonet/archive/2011/01/29/using-dbcontext-in-ef-feature-ctp5-part-4-add-attach-and-entity-states.aspx (part4) My questions are What does "Entity Tracked by Context" mean?? Does same context is used for every request or new

ToList method not available for TrackableCollection

徘徊边缘 提交于 2019-12-10 18:44:33
问题 We are working with Trackable Entities on top of EF 4.0. In order to delete an Entity with all its dependent entities I'm writing a generic DeleteDependentEntities to be called from the Delete method in the EntityManager. (We don't, or don't want to, rely on a CASCADE DELETE to be set on the relations in our database.) The DeleteDependentEntities scans recursevly all Children of the subjected entitySet. In order to keep it generic, so that it can be used for all entities throughout the

There is no property with name 'restriction_class_id' defined in type referred by Role 'phones_extensions'

落爺英雄遲暮 提交于 2019-12-10 18:08:45
问题 I created a new Entity Framework model from a database. This database has a number of tables, the main table is phones_extensions. The phones_extensions table has columns which are FK's to the other tables - e.g. the restriction_class_id is an FK linking to the phones_restictions_class table where the PK is ID. The EF4 model automatically generates associations for the tables. Great. Now when I run my application I see not only the numeric restriction_class_id but I also see the textual

Any way to speed up CreateIfNotExists in Entity Framework?

牧云@^-^@ 提交于 2019-12-10 17:57:12
问题 I'm using EF 4.3 Code First on SQL Server 2008. I run several test suites that delete and recreate the database with CreateIfNotExists. This works fine but is dog slow. It can take up to 15 seconds to create the database on the first call, and typically 3-6 seconds after that. I have several places where this is called. I've already optimized to call this as few times as I can. Is there something I can do to speed up database creation programmatically? I'm willing to go around EF to do this

Entity Framework use model for different providers

Deadly 提交于 2019-12-10 17:45:50
问题 I have an entity 4.0 model that is using a SqlServerCE database as its provider. On the server I want to use the same project and just switch out the connection string to use the actual SqlServer database. Here is my connection string <add name="Entities" connectionString="metadata=res://*/Entities.csdl|res://*/Entities.ssdl|res://*/Entities.msl; provider=System.Data.SqlClient; provider connection string=" Data Source=xxxx; Initial Catalog=xxxx;User ID=xxxx;Password=xxxx;"" providerName=

EF CTP4 cascade delete on many to many relationship

穿精又带淫゛_ 提交于 2019-12-10 17:37:58
问题 I've created a many to many relationship using default conventions in EF CTP4 by defining an ICollection on both image and project entities. The mapping table is created as below: create table [dbo].[Images_Project] ( [Images_Id] [uniqueidentifier] not null, [Project_Id] [uniqueidentifier] not null, primary key ([Images_Id])); Unfortunately when I delete a project it is not cascading deletes to the image mapping table. I would expect EF to generate a key on both the Imanges_Id and Project_Id

Entity framework code first - map class with List<> of another class to multiple tables?

青春壹個敷衍的年華 提交于 2019-12-10 17:37:42
问题 I'm evaluating EF4 and have a pretty basic question...I think, that I can't seem to find an answer for.. take the following example: public class Question { public string question {get;set;} public string answer {get; set;} } public class Person { public string Id {get; set;} public string Name {get; set;} public List<Question> Questions {get; set;} } Then I have the following tables in the database Person ( id, name ) Question ( id, personId, question, answer, ) Can I use the EF4 code first

What is the difference between Lazy Loading and Load()

穿精又带淫゛_ 提交于 2019-12-10 17:34:40
问题 In Entity Framework 4, what is the difference between Lazy Loading, and using Load() method? Edit: I have added, two 'if' statements: Lazy Loading: var query = from c in context.Contacts select c; foreach ( var contact in query ) { if ( contact.ID == 5 ) Console.WriteLine( contact.Addresses.City ); } Load() method: context.ContextOptions.LazyLoadingEnabled = false; var query = from c in context.Contacts select c; foreach ( var contact in query ) { if ( contact.ID == 5 ) { contact.Addresses

LINQ to SQL query has wrong values in results

隐身守侯 提交于 2019-12-10 17:26:32
问题 I have a LINQ query that has the incorrect results, but when I profile the SQL generated, the SQL results are correct. ApplicationsEntities context = new ApplicationsEntities(); var query = from documentation in context.Documnetations where documentation.Application_Version_ID == app_ver_id orderby documentation.Name select documentation; docs = query.ToList<Documnetation>(); I get back two duplicates : "How to install Office 2003" and "How to install office 2003" Below is the output of the