entity-framework-4.1

Tables without a clustered index are not supported in this version of SQL Server

↘锁芯ラ 提交于 2019-12-03 04:43:34
I am working on vs 2010 and EF 4.1 with SQL server database . Below mentioned code works fine with local SQL server DB.(SQL 2008). But when I published the MVC application for windows AZURE cloud and SQL Azure it's giving below mentioned error . Why this error is only return SQL Azure (working with desktop SQL server 2008)? How to get rid of this ? My repository code sample as below.Below mentioned error comes when calling Catalog.SaveChanges() method. using (var catalog = new DataCatalog()) { var retailSaleReturn = new RetailSaleReturn { ReturnQuantity = returnQuantity, Product =

Entity Framework 4.1 code first approach: how to define length of properties

喜欢而已 提交于 2019-12-03 04:32:44
As the title implies: how is it possible to tell Entity Framework 4.1 in code first approach, that i do want some properties (in particular of type string) to have a length of 256, or nvarchar(max), or... So if this is for example my model public class Book{ public string Title { get; set; } //should be 256 chars public string Description {get;set} //should be nvarchar(max) } how could it be defined? Thanks in advance! In EF4.1 RTW default length is nvarchar(max) for SQL Server and nvarchar(4000) for SQL CE. To change the length use either StringLength or MaxLength annotations or fluent

Entity Framework 4.1 - Override Entity (DBSet) with Filter

自古美人都是妖i 提交于 2019-12-03 03:52:30
I'm trying to do something which should be relatively easy, but i just dont know how to construct it. I have a Generated Entity which I'd like to override by adding a Linq Where statement. Herewith the partial for the Context : public partial class MyEntities: DbContext { public MyEntities() : base("name=MyEntities") { } public DbSet<Assignee> Assignees { get; set; } } I've created a new partial of MyEntities and tried the following public override DbSet<Assignee> Assignees { get { return this.Assignees.Where(z => z.IsActive == true); } set; } but this throws an ambiguity error (which is

Is there a performance difference between Model First and Code First in MS Entity Framework 4.1?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 03:29:32
I'm starting a new development and I plan to use Code First in Entity Framework 4.1. I have previously used Model First and found some performance issues around loading context, first calls to SaveChanges() and where Association Fix-up kicks in. Has anyone compared performance of these two techniques - or, at the end of the day are they insignificant? Thanks. I believe that there is no difference at all in performance. Code-First, Model-First, Database-First are modelling strategies at design time . For both Model-First and Database-First entity classes and a DbContext will be created with a

Entity Framework 4.1 Code First Foreign Key Id's

别等时光非礼了梦想. 提交于 2019-12-03 03:18:03
问题 I have two entities referenced one to many. When entity framework created the table it creates two foreign keys, one for the key I have specified with the fluent interface and the other for the ICollection. How do I get rid of the duplicate foreign key? public class Person { public long RecordId { get; set; } public string FirstName { get; set; } public string LastName { get; set; } public string Email { get; set; } public string Username { get; set; } public long DepartmentId { get; set; }

Why does DbSet.Add work so slow?

 ̄綄美尐妖づ 提交于 2019-12-03 02:44:29
问题 The same topic was discussed here 8 months ago: How do I speed up DbSet.Add()?. There was no solution proposed other than using SqlBulkCopy which is not acceptable for us. I've decided to bring it up once again hoping there might be new thoughts and ideas around this issue and other workarounds are proposed. At least I'm just curious why this operation takes so long time to run. Well, the problem is: I have to update 30K entities into database (EF 4.1, POCO). The entity type is quite simple

Deploy Entity Framework Code First

梦想与她 提交于 2019-12-03 02:06:24
I guess I should have thought of this before I started my project but I have successfully built and tested a mini application using the code-first approach and I am ready to deploy it to a production web server. I have moved the folder to my staging server and everything works well. I am just curious if there is a suggested deployment strategy? If I make a change to the application I don't want to lose all the data if the application is restarted. Should I just generate the DB scripts from the code-first project and then move it to my server that way? Any tips and guide links would be useful.

Linq for entities Framework 4.1 tutorials/ebooks links [closed]

三世轮回 提交于 2019-12-03 01:53:41
Is there any good LINQ tutorial for Entities Framework 4.1 Code First for medium to complex level? Please suggest books as well. Ladislav Mrnka For Linq-to-entities you can check MSDN: Syntax examples Linq-to-entities Sources for EFv4.1 code first are: ADO.NET team blog Morteza Manavi's blog Julia Lerman's blog Stack Overflow As I know there is no book covering EFv4.1 yet. Edit (May 2012): There are two books about EFv4.2 (Code first / DbContext API) now: Programming EF Code First Programming EF DbContext Just follow the ADO.NET blog. I've learnt so much from those articles/series! 来源: https:/

Entity Framework Code First Class with parent and children of same type as it's own class

那年仲夏 提交于 2019-12-03 01:28:29
I have a class of Content which should be able to have a parentId for inheritance but also I want it to have a list of child content which is nothing to do with this inheritance tree. I basically wanted a link table as ChildContentRelationship with Id's for parentContent and childContent in it and the Content class would have a list of ChildContentRelationship. This has caused a lot of errors. Here's waht I sort of want to do public class Content { public int Id { get; set; } public int? ParentContentId { get; set; } public virtual Content ParentContent { get; set; } public string Name { get;

EF 4.1 DbContext Generattor - Put Entities in different project?

可紊 提交于 2019-12-03 00:26:57
As a part of our application architecture, we like to define clear lines between our functional layers. A typical application solution, therefore, will contain: Entity Model Task Presenter FrontEnd These end up being completely distinct assemblies. The Entity/Model delineation is done to keep database access functionality in a separate layer from our POCOs, so that only Task ever need know about Model, while everyone up to Presenter knows about Entity This works well when using Code-First or Fluent-API - but due to the lack of support for SPROCs in those paradigms, it turns out that under EF 4