Is there a way to perform database schema generation with the Simple.Data library (similar to how Fluent NHibernate does it)?
If not, is there a way to run DDL (Data Definition Language) commands against a database via the Simple.Data library?
Currently in some integration tests I am creating a SQL CE database on the fly, auto generating the schema (via Fluent NHibernate), running the tests (accessing the database via Simple.Data), then deleting the database after the tests run (for cleanup).
It would be nice to be able to perform the DDL stuff using Simple.Data and remove the Fluent NHibernate dependency.
I recommend using Fluent Migrator for building DB schema (https://github.com/schambers/fluentmigrator/). It's what Simple.Data migrations would probably look like, so there seems little point reinventing the wheel.
Simple.Data 0.10 will have a new InMemory adapter which is schema-less, to reduce testing friction. Will be out by the end of November.
Related
By using "Code First" model programming is possible to create migrations do update database schema.
Is possible to create migrations to update database schema using ASP.Net Entity Framework and "DB First"?
Is possible to somehow update database schema (without data loss)?
You can do "Code First from an existing database" if that's what you mean. Here's a walkthrough.
This will create models for you in C# based on the existing database design, it's basically a one-time setup. From there you can use it as if you were Code First all along.
I have a project using NHibernate with XML mappings.
I'm modifying my integration test infrastructure so I can use an in-memory SQLite database rather than the SQL Server 2005 database we use in production.
However, I have a property mapping in one of my types that is not supported by SQLite. The column has a type of XML, and the entity property has a type of XDoc.
When I try to create my schema to set up my database:
SchemaExport se = new SchemaExport(configuration);
se.Create(true, true);
I get the error:
System.ArgumentException : Dialect does not support DbType.Xml
I know that I can modify my mappings at runtime, and that's what I'm attempting to do. But I can't figure out what needs to be done for this specific case so I can get this to work. Any help would be appreciated.
You can try subclassing the SQLite dialect class (and maybe also the corresponding NHibernate driver class) to map the XML types to some other type that SQLite can handle.
I'm learning Symfony2 and have just learnt about doctrine:migrations. It sounds like a great way of 'versioning' the database schema and deploying new schemas in production.
I've also been reading about data fixtures for development. Is there any way to version these in a similar fashion as the schema migrations, or should I just use GIT?
Migrations' versions have to be kept under version control. If GIT is your SCM, then it's fine.
Is there a way to check that a DbContext matches the database when the database was not created by EF code first?
I am looking for similar functionality to Database.CompatibleWithModel but there is not metadata.
There is currently no way in EF to do this; however, you may be able to use the DDL script as a starting point for verifying that all the artifacts exist in the database. To get this script, use
string ddlScript = ((IObjectContextAdapter)myContext).ObjectContext.CreateDatabaseScript();
Some tools may be able to use this script to do a schema compare against your database. This will tell you if your model is compatible.
Have you tried using Entity Framework Power Tools.
you can use the tools to Reverse Engineer Code First - Generates POCO
classes, derived DbContext and Code First mapping for an existing
database.
And then maybe you can compare the reversed engineered information with what you already have.
I am currently using SubSonic (2.2 and 3) for some ASP.NET projects and have managed to get them working with SQL Server (using ActiveRecord). However, I also want to know how to set it up with other (open source) databases, e.g. PostgreSQL and SQLite. This is so I can use it on a web host without SQL Server on. The providers I have found are:
PostgreSQL: Npgsql
SQLite: System.Data.SQLite or Mono.Data.SqliteClient (if it works with Microsoft.NET)
Anyone have any experience with SubSonic know how to do this (some sample demo would be good - just a basic primer on querying would be fine)? Non-ASP.NET MVC though (not got into it yet). I have only basic knowledge of SQLite (basically using SQLite Manager in Firefox and querying it via PHP Data Objects) and have not used Postgresql, but assume it would be more scalable than SQLite.
For version 3
PostgreSQL: There aren't any templates for postgres at the moment so you'd need to create the templates yourself
SQLite - The steps should be as follows:
Add a reference to System.Data.SQLite
Look in the TemplateProviders folder you'll find a SQLite.ttinclude which you'll need to drop into your project instead of SQLServer.ttinclude.
Change the .tt files that reference SQLServer.ttinclude to reference SQLite.ttinclude instead.
This is so I can use it on a web host without SQL Server on.
With the release of SQLExpress dont all hosts offer this? (I only use dedicated server so I have no direct experiance with this)
In response to your question.
SQLite - http://codefornothing.wordpress.com/2007/07/19/sqlite-data-provider-for-subsonic-part-2/
Postgre: Doesnt look as simple,
Subsonic postgreSQL Template
PostgreSQL via subsonic
Good luck.
In short, Subsonic only support few database only NOT ALL ( that what their claimed :( ). Try nHibernate, support most of the database.