Practice Management Book


Asp.Net Entity Framework

Aka: Asp.Net Entity Framework
  1. Precautions: Non-Medical
    1. Not for Medical Care
    2. The author uses several software packages and programming languages to develop FPnotebook content
    3. For convenience, a dozen pages in FPNotebook are dedicated to quick notes on content creation
  2. Approach: Code First
    1. Precautions
      1. Avoid changing database object class names (breaks the migrations)
        1. If this occurs, see corrupted database below
    2. Starting with mvc project with identity
      1. Open Package Manager (Alt-"/.") and select correct default project
      2. Type "Update-Database"
        1. If at non-powershell command prompt, type "dotnet ef database update"
    3. Subsequent migrations
      1. Open Package Manager (Alt-"/.") and select correct default project
      2. Type "Add-Migration MIGRATIONTITLE"
      3. Type "Update-Database"
    4. Reverse migration before update-database
      1. Remove-Migration
    5. Classes
      1. Foreign keys
        1. Set both an object property AND id property of the included object
          1. Example: NOTE class should have both a USER and USERID property
    6. Corrupted database
      1. Precaution: Eliminates all data in the database (use this method only in development)
      2. Delete the entire database in sql server object explorer
      3. Delete all the migrations in the data directory migrations folder
        1. Includes deleting the default migration for identity (0000..._CreateIdentitySchema.cs)
        2. Includes deleting ApplicationDbContextModelSnapshot.cs
      4. Re-run migrations
        1. Update-Database (uses the default identity migration)
        2. Type "Add-Migration MIGRATIONTITLE" (includes all other custom database dbsets)
        3. Type "Update-Database"
  3. Approach: Seed Data
    1. Sql script technique
      1. Create migration
        1. Add-Migration POPULATE_TABLE_NAME
      2. Create sql script into generate Up method
        1. Sql("Insert into TABLENAME(FIELDNAME) values ('dataitem')")

You are currently viewing the original '\legacy' version of this website. Internet Explorer 8.0 and older will automatically be redirected to this legacy version.

If you are using a modern web browser, you may instead navigate to the newer desktop version of fpnotebook. Another, mobile version is also available which should function on both newer and older web browsers.

Please Contact Me as you run across problems with any of these versions on the website.

Navigation Tree