Description:
Hello,
I'm using entity framework code-first approach to create tables in database.
This code is used to create tables:
var dbCreationScript = ((IObjectContextAdapter)context).ObjectContext.CreateDatabaseScript();
context.Database.ExecuteSqlCommand(dbCreationScript);
But generated script has errors.
1. It creates varbinary type from byte[] and does not specify the length of varbinary like "varbinary(0)".
With varbinary I get exception that script is incorrect.
With varbinary(0) it goes ok.
2. Incorrect alter table commands pointing to nonexist tables.
For example this class is used as entity:
public partial class ShippingMethod : BaseEntity, ILocalizedEntity
{
private ICollection<Country> _restrictedCountries;
/// <summary>
/// Gets or sets the name
/// </summary>
public virtual string Name { get; set; }
/// <summary>
/// Gets or sets the description
/// </summary>
public virtual string Description { get; set; }
/// <summary>
/// Gets or sets the display order
/// </summary>
public virtual int DisplayOrder { get; set; }
/// <summary>
/// Gets or sets the restricted countries
/// </summary>
public virtual ICollection<Country> RestrictedCountries
{
get { return _restrictedCountries ?? (_restrictedCountries = new List<Country>()); }
protected set { _restrictedCountries = value; }
}
}
As you can see its called "ShippingMethod". So I get create table shippingmethod command inside script that works fine and such table is created.
But I also get ALTER TABLE ShippingMethodCountry that does not exist and should not be exist because no such class was ever created.
As I understand it is created because of private ICollection<Country>. But this alter table should point to ShippingMethod table instead (as i think).
(trying to implement mysql in nopcommerce)
Thanks.
How to repeat:
I can post full source to fileshare. But i think you can repeat it with class mentioned.