Skip to content

Commit

Permalink
Update osx/linux guides to include work arounds for issues in beta6
Browse files Browse the repository at this point in the history
  • Loading branch information
Nate McMaster committed Jul 29, 2015
1 parent ffe944b commit 522124a
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 12 deletions.
7 changes: 2 additions & 5 deletions docs/getting-started/linux.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ Minimum system requirements
.. caution::
**Known Issues**

- Bugs in Mono 4.0.2 may cause Entity Framework to crash when using async methods. This is resolved with Mono >4.2.0, which has not yet been publicly released. `See this issue on GitHub <https://github.com/aspnet/EntityFramework/issues/2708>`_
- Migrations on SQLite do not support more complex schema changes due to limitations in SQLite itself.

.. TODO add workaround demo for SQLite rebuilds
.. include:: x-plat/issues.rst


Install ASP.NET 5
Expand Down Expand Up @@ -81,4 +78,4 @@ The following steps will install `dnvm <https://github.com/aspnet/home#running-a
If you have trouble installing dnvm, consult this `Getting Started guide <http://dotnet.github.io/core/getting-started/>`_.


.. include:: xplat.rst
.. include:: x-plat/guide.rst
8 changes: 2 additions & 6 deletions docs/getting-started/osx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,7 @@ Minimum system requirements
.. caution::
**Known Issues**

- Bugs in Mono 4.0.2 may cause Entity Framework to crash when using async methods. This is resolved with Mono >4.2.0, which has not yet been publicly released. `See this issue on GitHub <https://github.com/aspnet/EntityFramework/issues/2708>`_
- Migrations on SQLite do not support more complex schema changes due to limitations in SQLite itself.

.. TODO add workaround demo for SQLite rebuilds
.. include:: x-plat/issues.rst

Install ASP.NET 5
-----------------
Expand Down Expand Up @@ -67,4 +63,4 @@ The following steps will install `dnvm <https://github.com/aspnet/home#running-a
If you have trouble installing dnvm, consult this `Getting Started guide <http://dotnet.github.io/core/getting-started/>`_.


.. include:: xplat.rst
.. include:: x-plat/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,43 @@ Run the application from the command line.
After adding the new post, you can verify the data has been added by inspecting the SQLite database file, ``blog.db``.


Workarounds
-----------

This demo was written for beta 6, which has bugs in it. The following workarounds will make this sample project work for beta 6.

Add a Startup class to your project
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

When generating migrations, you may see this error message:

.. code-block:: console
System.InvalidOperationException: A type named 'StartupProduction' or 'Startup' could not be found in assembly 'ConsoleApp'.
To get around this, add the following into your project.

.. literalinclude:: x-plat/sample/src/ConsoleApp/Program.cs
:linenos:
:language: c#
:lines: 25-30


Migrations generates invalid annotation
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

In this sample, the first step of `Create your database`_ will generate invalid
C#. You may encounter this error when building your project.

.. code-block:: console
Microsoft.Framework.Runtime.Roslyn.RoslynCompilationException: ./src/ConsoleApp/Migrations/20150729221913_MyFirstMigration.cs(17,61): DNX,Version=v4.5.1 error CS1503: Argument 2: cannot convert from 'bool' to 'string'
To get around this, remove the offending lines of the code in ``Migrations/xxxxx_MyFirstMigration.cs```.

.. literalinclude:: x-plat/sample/src/ConsoleApp/Migrations/20150729221913_MyFirstMigration.cs
:linenos:
:language: c#
:lines: 8-32
:emphasize-lines: 10, 23
6 changes: 6 additions & 0 deletions docs/getting-started/x-plat/issues.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- Bugs in Mono 4.0.2 may cause Entity Framework to crash when using async methods. This is resolved with Mono >4.2.0, which has not yet been publicly released. `See aspnet/EntityFramework#2708 <https://github.com/aspnet/EntityFramework/issues/2708>`_ on GitHub
- Migrations on SQLite do not support more complex schema changes due to limitations in SQLite itself.

- Bugs in beta 6. See `Workarounds`_.
- Migrations requires that you have a "Startup" class in your project. `Issue #2357 <https://github.com/aspnet/EntityFramework/issues/2357>`_.
- Migrations adds an annotation that will cause a build error. `Issue #2545 <https://github.com/aspnet/EntityFramework/issues/2545>`_.
4 changes: 4 additions & 0 deletions docs/getting-started/x-plat/sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
Thumbs.db
project.lock.json
*.db

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System.Collections.Generic;
using Microsoft.Data.Entity.Migrations;
using Microsoft.Data.Entity.Migrations.Builders;
using Microsoft.Data.Entity.Migrations.Operations;

namespace ConsoleAppMigrations
{
public partial class MyFirstMigration : Migration
{
public override void Up(MigrationBuilder migration)
{
migration.CreateTable(
name: "Blog",
columns: table => new
{
BlogId = table.Column(type: "INTEGER", nullable: false),
// .Annotation("Sqlite:Autoincrement", true),
Name = table.Column(type: "TEXT", nullable: true),
Url = table.Column(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Blog", x => x.BlogId);
});
migration.CreateTable(
name: "Post",
columns: table => new
{
PostId = table.Column(type: "INTEGER", nullable: false),
// .Annotation("Sqlite:Autoincrement", true),
BlogId = table.Column(type: "INTEGER", nullable: false),
Content = table.Column(type: "TEXT", nullable: true),
Title = table.Column(type: "TEXT", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Post", x => x.PostId);
table.ForeignKey(
name: "FK_Post_Blog_BlogId",
columns: x => x.BlogId,
referencedTable: "Blog",
referencedColumn: "BlogId");
});
}

public override void Down(MigrationBuilder migration)
{
migration.DropTable("Post");
migration.DropTable("Blog");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;
using Microsoft.Data.Entity.Migrations.Infrastructure;
using ConsoleApp;

namespace ConsoleAppMigrations
{
[ContextType(typeof(BloggingContext))]
partial class BloggingContextModelSnapshot : ModelSnapshot
{
public override void BuildModel(ModelBuilder builder)
{
builder
.Annotation("ProductVersion", "7.0.0-beta6-13815");

builder.Entity("ConsoleApp.Blog", b =>
{
b.Property<int>("BlogId")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.Property<string>("Url");
b.Key("BlogId");
});

builder.Entity("ConsoleApp.Post", b =>
{
b.Property<int>("PostId")
.ValueGeneratedOnAdd();
b.Property<int>("BlogId");
b.Property<string>("Content");
b.Property<string>("Title");
b.Key("PostId");
});

builder.Entity("ConsoleApp.Post", b =>
{
b.Reference("ConsoleApp.Blog")
.InverseCollection()
.ForeignKey("BlogId");
});
}
}
}
9 changes: 8 additions & 1 deletion docs/getting-started/x-plat/sample/src/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class Program
{
public void Main(string[] args)
{
using (var context = new BloggingContext())
using (var db = new BloggingContext())
{
db.Blogs.Add(new Blog { Url = "http://blogs.msdn.com/adonet" });
var count = db.SaveChanges();
Expand All @@ -21,4 +21,11 @@ public void Main(string[] args)
}
}
}

// TODO: Remove. Will be unnecessary when bug #2357 fixed
// See https://github.com/aspnet/EntityFramework/issues/2357
public class Startup
{
public void Configure() { }
}
}

0 comments on commit 522124a

Please sign in to comment.