sql-server-ce

How to delete all data in a table in SQL CE?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-01 08:05:11
问题 SQL CE does not support TRUNCATE command. To clear a table I have to use DELETE. Is there a quicker/better way to clear the data then the following command? DELETE FROM FooTable WHERE id !='ABC' 回答1: You don't have any better way to do that, DELETE is the SQL Command for SQL CE to DELETE ROWS, anyway TRUNCATE TABLE deletes every row in a table, so your DELETE query must be executed also at SQL Server if you want to DELETE all the rows with id different from 'ABC'. In the case you want to

How to delete all data in a table in SQL CE?

ぃ、小莉子 提交于 2020-01-01 08:05:10
问题 SQL CE does not support TRUNCATE command. To clear a table I have to use DELETE. Is there a quicker/better way to clear the data then the following command? DELETE FROM FooTable WHERE id !='ABC' 回答1: You don't have any better way to do that, DELETE is the SQL Command for SQL CE to DELETE ROWS, anyway TRUNCATE TABLE deletes every row in a table, so your DELETE query must be executed also at SQL Server if you want to DELETE all the rows with id different from 'ABC'. In the case you want to

EF Code First thinks database is out of date — only in production

和自甴很熟 提交于 2020-01-01 03:42:05
问题 I have an ASP.NET MVC 3 app that is using SQL Server CE 4.0 and Entity Framework 4.1 Code First. It works fine locally , but in production, it fails with the following error: The model backing the 'foobar' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and

Two different providers on the same config file

只愿长相守 提交于 2020-01-01 03:17:25
问题 Im using EntityFramework 6.1.0 I have 2 providers . MysqlClient and SQLServerCE, and i need to create 2 different DBContext. That forced me to create 2 configuration classes because mysql have some different things. But when i initialize the application, the Database.DefaultConnectionFactory is from the defaultConnectionFactory(config file) , and i cant specify what provider to take on the daterminated Context. How to do it? My config file: <entityFramework> <defaultConnectionFactory type=

How to Move a Tracked File to Untracked using Visual Studio Tools for Git

一世执手 提交于 2019-12-30 04:47:34
问题 Started experimenting with git. Inadvertently added all the files in the project to "Included Changes" in Team Explorer. I committed all in an initial commit. One of those files was the SQL CE 4.0 (file-based) database. I clearly goofed there. I do not want to track the database nor do I want to end up restoring the db back to some previous point. My problem is I have no idea of how to move the SQL CE 4.0 sdf file from included changes to untracked. I am not experienced with git and all I

SQL Server queries case sensitivity

◇◆丶佛笑我妖孽 提交于 2019-12-30 02:43:31
问题 I have this database: abcDEF ABCdef abcdef if I write: select * from MyTbl where A='ABCdef' how to get: ABCdef and how to get: abcDEF ABCdef abcdef Thanks in advance forgot to write - sqlCE 回答1: You can make your query case sensitive by making use of the COLLATE keyword. SELECT A FROM MyTbl WHERE A COLLATE Latin1_General_CS_AS = 'ABCdef' 回答2: If you have abcDEF, ABCdef, abcdef already in the database then it's already case sensitive or you have no constraint. You'd have to add a COLLATE on

Error on using TransactionScope in EF4 & SQL Compact 4

时光毁灭记忆、已成空白 提交于 2019-12-29 09:27:12
问题 using (TransactionScope scope = new TransactionScope()) using (var context = new dwfEntities()) { var field = (from x in context.DynFields where x.Id == id select x).First(); //delete defaults foreach (var item in from x in context.DynFieldDefaults where x.DynField_Id == id select x) { context.DeleteObject(item); } context.SaveChanges(); //delete field context.DeleteObject(field); context.SaveChanges(); //commit scope.Complete(); } The code throws "The connection object can not be enlisted in

How to use SQL Server Compact Edition (CE) from Java?

这一生的挚爱 提交于 2019-12-29 07:40:10
问题 I want to access Microsoft SQL Server Compact Edition databases from Java. How can I do that? I searched for JDBC driver for SQLCE, but I didn't find any. 回答1: According to a newsgroup post sent this Tuesday (2008-12-09) by Jimmy Wu@Mircrosoft: The Microsoft SQL Server JDBC Driver does not support connecting to SQL Server Compact. At this time there isn't a scheduled JDBC support for SQL Server Compact edition. Thank-you for your continuing support of SQL Server. Sincerely, Jimmy Wu 回答2:

Connection string for using SQL Server Compact with Entity Framework?

限于喜欢 提交于 2019-12-29 06:14:21
问题 I'm done trying to Google for this. I have installed SQL Server CE 4.0, and have EF 4.1, but I can't get a proper connection string. Nothing on connectionstrings.com applies to me. I just want to create a SqlCeEngine object, but no matter what I try I get some exception. Most recently it's been Unknown connection option in connection string with either "metadata", "app", "provider", or "provider connection string" after it. I know EF requires metadata in the connection string. And I can't

Cascade Delete Rule in EF 4.1 Code First when using Shared Primary Key Association

旧街凉风 提交于 2019-12-28 16:02:48
问题 I implemented a bidirectional 1:1 relationship based on this answer: Primary /Foreign Key in Entity Framework I define the bidirectional relation this way: public class Student { public virtual int StudentId { get; set; } public virtual Anamnesis Anamnesis { get; set; } . . . } public class Anamnesis { [Key, ForeignKey("Student")] public int AnamnesisId { get; set; } public virtual Student Student { get; set; } . . . } where, Student is the principal entity and Anamnesis it the entity that