sql-server-ce

Designing data access for Compact Framework and Full Framework

孤街浪徒 提交于 2019-12-05 15:48:19
We currently have a desktop app which uses data from SQL CE. We used Entity Framework for our ORM layer to the database and all data access methods are built around this. Now we have to build a smaller scaled down "clone" of this app for Windows CE 6.0 on the Compact Framework, also using the same SQL CE database design as on the desktop version. The problem is that compact framework does not support Entity Framework, so we are forced to access the database the old fashioned way (ADO.net, datasets, etc). However this is causing duplication of our whole data access layer and maintenance on

EF & WCF error - SQL Server Compact is not intended for ASP.NET development

萝らか妹 提交于 2019-12-05 14:03:24
Hi I have a simple wpf app setup to consume my test wcf service running in another project. The service retrieves a few rows from a sql compact 3.5 sdf attached to the wcf service project using Entity Framework. Im getting the "SQL Server Compact is not intended for ASP.NET development." error on the 1st line of the of my object context class in the service project as soon as I try and run one of the services. This error supposedly can be suppressed with "AppDomain.CurrentDomain.SetData("SQLServerCompactEditionUnderWebHosting", true);" in the global.asmx file. However this is not an asp.net

How do I rename a table in SQL Server Compact Edition?

主宰稳场 提交于 2019-12-05 12:11:21
问题 I've designed my SQL CE tables using the built-in designer in VS2008. I chose the wrong names for a couple. I am now completely stuck trying to find a way to rename them. I am refusing to believe that such a feature could have been "forgotten". How do I rename an existing table using the VS2008 designer, or a free stand-alone app? 回答1: Not sure about doing it via VS2008, but you can use sp_rename : Changes the name of a user table in the current database. Currently, sp_rename support in SQL

Inserting into SQL Server CE database file and return inserted id

断了今生、忘了曾经 提交于 2019-12-05 11:57:57
Problem is : My query INSERT INTO TableName(val1,val2)values(1,2); SELECT @@IDENTITY; When I run it in run query from server explorer I get the correct result. But when I use ExecuteScalar or ExecuteDataTable I get an error ,... query return null public object ExecuteScalre(string Query, CommandType type) { OpenConnection(); cmd.CommandText = Query; cmd.CommandType = type; object obj = null; try { obj = cmd.ExecuteScalar(); } catch { } finally { ReleaseResource(); } return obj; } public DataTable ExecuteDataTable(string Query, CommandType type) { OpenConnection(); cmd.CommandText = Query; cmd

How do I efficiently store all OpenStreetMap data in an indexed way?

萝らか妹 提交于 2019-12-05 10:38:24
Note: While I target Windows Phone 7, it doesn't introduce anything besides a size restriction. In an attempt to write a GPS / Routing / Map application for the Windows Phone 7, I'm trying to attempt to use OpenStreetMap for this and I want to get my data stored in a SQL Server Compact Edition database on my Windows Phone 7 . This is giving me a lot of trouble so I'm getting clueless what the right way is... Here is my progress: I've downloaded Belgium.osm.pbf , which contains all the Belgium OSM data in PBF format . Note that Belgium isn't that large, it's the country I live in so it seems as

SQL Server Compact Edition 4 - AccessViolationException

China☆狼群 提交于 2019-12-05 09:37:21
I'm building a .NET 4 WPF application using Entity Framework code first and SQL Server Compact 4.0. I'm trying to call DbContext.SaveChanges() on a background thread to avoid blocking the UI, but I'm occasionally getting the following exception: System.AccessViolationException occurred Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source=System.Data.SqlServerCe StackTrace: at System.Data.SqlServerCe.NativeMethodsHelper.OpenStore(IntPtr pOpenInfo, IntPtr pfnOnFlushFailure, IntPtr& pStoreService, IntPtr& pStoreServer, IntPtr&

extract schema for sql server compact edition

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-05 07:09:30
Is there a way to generate the sql statement for tables in sql server compact ? same as for sql server express+ ? Essentially a create table( .... ) statement as output ? There is a project on Codeplex that someone has actually built the functionality to be able to do scripting for sql server compact edition databases. There is a tool to do this. Check out http://www.antipodeansoftware.com/Home/Products This will iterate the entire SQL server, and write all the table, view, stored procedure and UDF scripts to a local drive. Great for adding SQL schema or DDL to source control. The plugin

Entity Framewok Code First “ADO.NET provider not found” with local SQL Server CE DLL's

限于喜欢 提交于 2019-12-05 03:51:25
I am writing a C# application which uses SQL Server CE 4.0 files, which are accessed through the Entity Framework 6.0 via code-first. (The application needs to be able to use local dll's for the SQL Server CE connection i.e. the application needs to be XCOPY deployable). The application runs fine on my development machine, but on other machines (e.g. VMs with just Win7 and .NET 4.0), I get an ArgumentException : The ADO.NET provider with invariant name 'System.Data.SqlServerCe.4.0' is either not registered in the machine or application config file, or could not be loaded. See the inner

The column name is not valid. [ Node name (if any) = t0,Column name = version ]

孤街醉人 提交于 2019-12-05 03:34:41
I am facing issue while trying to query SQLCE database in my Windows Phone Mango application. I get exception when I execute foreach (var item in myDataContext.MyTable.Select(item => item)) The column name is not valid. [ Node name (if any) = t0,Column name = version ] Strangely, when I execute query based on any individual column, it works fine foreach (var item in myDataContext.MyTable.Select(item => item.SomeColumn)) Any idea what could be wrong here? I installed LINQ to SQL Debug Visualizer to find out what query exactly is being generated behind the scene and it was {SELECT [t0].[version]

How do I get the Entity Framework to initialise collections on my newly-created entities?

半腔热情 提交于 2019-12-05 03:33:07
I'm trying to seed my database with some test data with an IDatabaseIntialiser like this: protected override void Seed(BlogDataContext context) { // <snip> var post = context.Posts.Create(); post.Title = "My Life On Twitter"; // <snip properties> // Set tags post.Tags.Add(aspnetTag); // NullRefException post.Tags.Add(razorTag); Post entity looks like this: public class Post { // ... public virtual ICollection<Tag> Tags { get; set; } Full entities at Bitbucket: Post and Tag . All code is at http://code.dantup.com/blog However, post.Tags is null, so this doesn't work. Originally I was creating