sql-server-ce

How do you create a foreign key relationship in a SQL Server CE (Compact Edition) Database?

半世苍凉 提交于 2019-12-03 10:26:46
问题 Visual Studio 2005 doesn't provide an interface for creating relationships between tables in a SQL Server CE database (I'm using version 3.0) and you can't open a Compact Edition DB using Management Studio as far as I know. Any ideas? 回答1: Unfortunately there is currently no designer support (unlike for SQL Server 2005) for building relationships between tables in SQL Server CE. To build relationships you need to use SQL commands such as: ALTER TABLE Orders ADD CONSTRAINT FK_Customer_Order

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

落花浮王杯 提交于 2019-12-03 10:03:52
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 optionally seed it with new data. I've verified that my application dll and database file are up-to-date on the

LEFT OUTER JOIN with a WHERE clause

倖福魔咒の 提交于 2019-12-03 09:46:09
I have two tables. indRailType contains a list of the names paired with an ID value that I use in other tables to indicate the rail type. WO_BreakerRail contains a date column and a rail code column that corresponds to the same code in indRailType and some other data. There's a row in WO_BreakerRail for any activity on each rail type, for every date. So I could have 3 rows dated for 3/19/2010 , each row indicates a different rail code, and what happened. When I use the following LEFT OUTER JOIN , I get a table with all the types of rail, with nulls in the rows where nothing happened on the

Two different providers on the same config file

不羁岁月 提交于 2019-12-03 08:24:15
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="System.Data.Entity.Infrastructure.SqlCeConnectionFactory, EntityFramework"> <parameters> <parameter value

Would you use Sql Server Compact for a desktop application? [closed]

混江龙づ霸主 提交于 2019-12-03 07:45:49
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . Does it make sense to use SQL Server Compact for a desktop application? How much data can it handle? Is it possible to use it with

Entity Framework Code-First: How to manually update the database?

狂风中的少年 提交于 2019-12-03 06:48:14
问题 I've build a little WPF demo app which uses EF Code-First to save its data in a SQL CE 4.0 DB. It works fine unless I remove a property from a model object. For example, if I remove "HosteBy" from this class..... public class Dinner { public int DinnerID { get; set; } public string Title { get; set; } public DateTime EventDate { get; set; } public string Address { get; set; } public string HostedBy { get; set; } public virtual ICollection<RSVP> RSVPs { get; set; } } ...it throws this

Determine if table exists in SQL Server CE?

我的梦境 提交于 2019-12-03 05:52:34
I know this is similar to this question , but I'm using SQL Server CE 3.5 with a WinForms project in C#. How can I determine whether a table exists? I know the IF keyword is not supported, though EXISTS is. Does information_schema exist in CE where I can query against it? Thanks. Yes, it does exist: SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'TableName' As an alternative you can Query the Table and catch the Exception thrown. If there is an Exception, the Table wasn't found, else the Table exists. SELECT TOP 1 1 FROM TableName; A little and simple Performance Test had better

How Convert SQL CE 3.5 database to SQLite

爱⌒轻易说出口 提交于 2019-12-03 03:07:29
I started a project using SQL CE 3.5 in Visual Studio 10. But now I found out that the database is very slow. I did some testing on SQLite and thi is much faster. Is there a way that I easily can convert de SQL CE 3.5 (sdf) database to SQLite? I have a tool to "dump" an entire SQL Compact file as SQL script, that you can then run against a SQLite db - http://exportsqlce.codeplex.com Doug Currie Export CSV file(s) from SQL CE, import into SQLite, or Use ODBC to connect to both databases and move data from one to the other 来源: https://stackoverflow.com/questions/5303797/how-convert-sql-ce-3-5

Would you use Sql Server Compact for a desktop application? [closed]

社会主义新天地 提交于 2019-12-02 20:28:58
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Does it make sense to use SQL Server Compact for a desktop application? How much data can it handle? Is it possible to use it with multiple users? What are the constraints? What happens when database files are broken? Is it possible to programmatically

Entity Framework Code-First: How to manually update the database?

佐手、 提交于 2019-12-02 20:27:56
I've build a little WPF demo app which uses EF Code-First to save its data in a SQL CE 4.0 DB. It works fine unless I remove a property from a model object. For example, if I remove "HosteBy" from this class..... public class Dinner { public int DinnerID { get; set; } public string Title { get; set; } public DateTime EventDate { get; set; } public string Address { get; set; } public string HostedBy { get; set; } public virtual ICollection<RSVP> RSVPs { get; set; } } ...it throws this exception: The model backing the 'NerdDinners' context has changed since the database was created. Either