entity-framework-4

Entity Framework on SQL Server CE without driver install

家住魔仙堡 提交于 2019-12-13 16:05:26
问题 I'm developing a WPF application using Entity Framework 4 and SQL Server CE database 3.5 and it's correctly working. However I'd like to have this application to run on a machine with .Net Framework 4 installed but without the SQL Server Compact 3.5 drivers. And no installer. Is it possible? I have tried the following: create a section in the app.config <configuration> <connectionStrings> <add name="DbEntities" connectionString="metadata=res://*/Model.Model1.csdl|res://*/Model.Model1.ssdl|res

Entity framework OptimisticConcurrencyException rethrown after refresh

别等时光非礼了梦想. 提交于 2019-12-13 15:37:52
问题 I'm using a timestamp column to check the concurrency in my entity. The exception is correctly thrown when data is not the same in 2 different contexts. When such an exception occurs when saving, I call the following method to handle it: public static void HandleOptimisticConcurrencyException(ObjectContext context, OptimisticConcurrencyException ex) { string msg = @"The data has changed while you were editing it. If you save, your changes will override the previous ones. If you don't, your

How to pass null values into stored procedure via Entity Framework?

微笑、不失礼 提交于 2019-12-13 15:21:12
问题 I am using an ASP.NET MVC 4 application with Entity Framework. I want to pass null values conditionally, let's say if pass value into DeptID then it should list of values for only passed DeptID , and if pass DeptID = NULL then it should it all the departments. I wrote a procedure by checking DeptID and it returns the desired output (if DeptID is null , then all rows are returned). But problem is to when I want to pass null values through following code of Entity Framework it is not working.

Entity Framework 4.1 Code-First approach to realize many-to-many relation over Domain-Services

♀尐吖头ヾ 提交于 2019-12-13 15:14:10
问题 I had some problems while creating a database model using the newest Entity Framework and Code-First (see Entity Framework 4.1 Code First approach to create many-to-many relation for details). Meanwhile I've figured out that the problem isn't the Entity Framework itself any more, but using it along with WCF RIA DomainServices. For the sake of completeness - that's my relevant Code-First code: // // Models // public class Author { public Author() { this.Books = new Collection<Book>(); }

The specified type member 'DateTime' is not supported in LINQ to Entities

ぐ巨炮叔叔 提交于 2019-12-13 15:11:20
问题 I am using the latest development version of the connector - 6.3.3 beta to connect to a mysql database via the Entity Framework 4 in VS2010. I have the following Linq statement which uses a TIMESTAMP column - createdDate - in the query. Here is the code: int timeThreshold = 5; DateTimeOffset cutoffTime = DateTime.Now.AddMinutes(-timeThreshold); using (var context = new opusismEntities()) { var unprocessedMessages = from m in context.messages where m.createdDate <= cutoffTime select m; try {

EF4 - Force order of execution

一曲冷凌霜 提交于 2019-12-13 14:59:04
问题 I have three tables - Context, Session and User. And below are their simplified structure. User: UserId (Int, PK) Email (Varchar(100)) Context: ContextId (Int, PK) UserId (Int, FK from User table) CurrentSessionId (Int, Nullable, FK from Session table) Session: SessionId (Int, PK) UserId (Int, FK from User table) ContextId (Int, FK from Context table) Below is the sequence in my code to delete a user entity. 1) Update CurrentSessionId of Context table to null where UserId = UserId to be

In Entity Framework 4.0 “Nested transactions are not supported” error is displayed?

旧街凉风 提交于 2019-12-13 14:15:54
问题 An error occurred while starting a transaction on the provider connection. See the inner exception for details. "Nested transactions are not supported." Inner Exception public bool Insert(myModel model) { entities.Database.Connection.Open(); using (DbTransaction trans = entities.Database.Connection.BeginTransaction()) { try { table1 obj1 = new table1 { AccountHolderName = model.AccountHolderName, AccountNumber = model.AccountNumber, Address = model.Address, }; entities.table1.Add(obj1);

The specified LINQ expression contains references to queries that are associated with different contexts

青春壹個敷衍的年華 提交于 2019-12-13 13:24:39
问题 I'm getting an error when trying to join against multiple tables in a query: The specified LINQ expression contains references to queries that are associated with different contexts It's confusing because it makes it seem like I'm using different contexts within the query but I'm not: public static IQueryable<Company> GetAll(bool supportsMMAT) { return from c in Context.Companies join v in Context.Vehicles on c.CompanyIdNumber equals v.CompanyIdNumber join mt in Context.ModemTypes on v

Selecting & Updating Many-To-Many in Entity Framework 4

爱⌒轻易说出口 提交于 2019-12-13 13:13:58
问题 I am relatively new to the EF and have the following entity model above which consists of an Asset and a Country. An Asset can belong in many countries and thus has a many-to-many relationship with country (has a join table in the database with two fields both as primary keys). I want to be able to do the following: Firstly when I retrieve an asset (or assets) from the model I want to get the respective countries that its associated with. I would then like to be able to bind the countries

EF4 CTP5 Code First approach ignores Table attributes

坚强是说给别人听的谎言 提交于 2019-12-13 09:17:18
问题 I'm using EF4 CTP5 code first approach but am having trouble getting it to work. I have a class called "Company" and a database table called "CompanyTable". I want to map the Company class to the CompanyTable table, so have code like this: [Table(Name = "CompanyTable")] public class Company { [Key] [Column(Name = "CompanyIdNumber", DbType = "int")] public int CompanyNumber { get; set; } [Column(Name = "CompanyName", DbType = "varchar")] public string CompanyName { get; set; } } I then call it