entity-framework-4.1

Manually editing database in code first entity framework

谁说胖子不能爱 提交于 2019-12-21 04:00:18
问题 I have been trying out EF 4.1 ( code first ) with MVC 3. I am thinking ahead to when the application will need changes. I tested a couple of scenarios. I like the idea of manually editing the database when the model (my POCOs) would changed. ASP.NET error when I change the model : "The model backing the 'CTCMContext' context has changed since the database was created. Either manually delete/update the database..." Now, it says that I can " manually update the database ", but I did and still

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 can I return a datareader when using Entity Framework 4?

白昼怎懂夜的黑 提交于 2019-12-21 03:31:06
问题 I want to define a database query using LINQ and my EntityFramework context but I don't want entities returned; I want a datareader! How can I do this? This is for exporting rows to a CSV. Cheers, Ian. 回答1: This question is around EF 4, but for anyone else with EF 6 or higher you can use the AsStreaming() extension method. http://msdn.microsoft.com/en-us/library/dn237204(v=vs.113).aspx 回答2: If you need this you are more probably doing something unexpected. Simple iteration through

Entity Framework Code First Mapping

旧时模样 提交于 2019-12-21 01:39:11
问题 I have two classes, the Group class has a many to many relationship with the User class (representing the groups a user belongs to) and then the group also has a relationship of one to many with the user class (representing the owner of a group). How can I map this? public class User { public int Id { get; set; } public string Avatar { get; set; } public string Name { get; set; } public string Message { get; set; } public virtual ICollection<Group> OwnedGroups { get; set; } public virtual

Entity Framework Code First Mapping

亡梦爱人 提交于 2019-12-21 01:39:09
问题 I have two classes, the Group class has a many to many relationship with the User class (representing the groups a user belongs to) and then the group also has a relationship of one to many with the user class (representing the owner of a group). How can I map this? public class User { public int Id { get; set; } public string Avatar { get; set; } public string Name { get; set; } public string Message { get; set; } public virtual ICollection<Group> OwnedGroups { get; set; } public virtual

Entity Framework 4.1 for large number of tables (715)

こ雲淡風輕ζ 提交于 2019-12-20 18:54:09
问题 I'm developing a data access layer for a database with over 700 tables. I created the model including all the tables, which generated a huge model. I then changed the model to use DBContext from 4.1 which seemed to improve how it compiled and worked. The designer didnt seem to work at all. I then created a test app which just added two records to the table, but the processor went 100% in the db.SaveChanges method. Being a black box it was difficult to accertain what went wrong. So my

Entity Framework 4.1 for large number of tables (715)

做~自己de王妃 提交于 2019-12-20 18:54:09
问题 I'm developing a data access layer for a database with over 700 tables. I created the model including all the tables, which generated a huge model. I then changed the model to use DBContext from 4.1 which seemed to improve how it compiled and worked. The designer didnt seem to work at all. I then created a test app which just added two records to the table, but the processor went 100% in the db.SaveChanges method. Being a black box it was difficult to accertain what went wrong. So my

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

蹲街弑〆低调 提交于 2019-12-20 18:02:27
问题 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())

Deploy Entity Framework Code First

…衆ロ難τιáo~ 提交于 2019-12-20 12:04:04
问题 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