I have ValueObject that later is a prop of an Entity VO is Address below
public class Address : ValueObject<Address>
{
public int CountryId { get; private set; } //A reference to a Country entity.
public string City { get; private set; }
public string Street { get; private set; }
public string PostalCode { get; private set; }
public int Number { get; private set; }
public Address(int countryId, string city, string street, int number, string postalCode)
{
CountryId = countryId;
City = city;
Street = street;
Number = number;
PostalCode = postalCode;
}
}
When doing Add-Migration "whatever" I get
System.InvalidOperationException: The entity type 'Address' requires a primary key to be defined.
at Microsoft.EntityFrameworkCore.Internal.ModelValidator.ShowError(String message)
at Microsoft.EntityFrameworkCore.Internal.ModelValidator.Validate(IModel model)
at Microsoft.EntityFrameworkCore.Internal.RelationalModelValidator.Validate(IModel model)
at Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext context, IConventionSetBuilder conventionSetBuilder, IModelValidator validator)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at Microsoft.EntityFrameworkCore.Internal.DbContextServices.CreateModel()
at Microsoft.EntityFrameworkCore.Internal.LazyRef`1.get_Value()
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitTransient(TransientCallSite transientCallSite, ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.<>c__DisplayClass16_0.<RealizeService>b__0(ServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.EntityFrameworkCore.Design.Internal.MigrationsOperations.AddMigration(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name, String outputDir, String contextType)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
The entity type 'Address' requires a primary key to be defined.
PM>
In the ABP documentation I do not see the PK definition!
<a class="postlink" href="https://aspnetboilerplate.com/Pages/Documents/v2.0.1/Value-Objects">https://aspnetboilerplate.com/Pages/Doc ... ue-Objects</a>
Where can I get ASP.NET Zero 4.1 from Git?
for those who wnat to connect different applications to the AspNetZero framework using REST API
the API has been auto-generated with Visual Studio 2017 using the "Add -> REST Api Client..." function Client Namespace: AspNetZeroWebHost Swagger Url: <a class="postlink" href="http://localhost:22742/swagger/v1/swagger.json">http://localhost:22742/swagger/v1/swagger.json</a>
then just use the AspNetZeroWebHostClient to call the server
var credentials = new TokenCredentials("what ever here");
var client = new AspNetZeroWebHost.AspNetZeroWebHostClient(new Uri("http://localhost:22742", UriKind.Absolute), credentials);
var customHeaders = new Dictionary<string, List<string>>
{
{ "Abp.TenantId", new List<string> { "1" } }
};
Task<HttpOperationResponse<AuthenticateResultModel>> ar = client.ApiTokenAuthAuthenticatePostWithHttpMessagesAsync(
new AspNetZeroWebHost.Models.AuthenticateModel("username", "userpassword"),
customHeaders);
ar.Wait();
customHeaders.Add("Authorization", new List<string> { "Bearer " + ar.Result.Body.AccessToken });
var aa = client.ApiTokenAuthGetExternalAuthenticationProvidersGetWithHttpMessagesAsync(customHeaders);
aa.Wait();
Important thing: The generated code has one problem when deserializing the respinse. Work arround is:
public static class AnzSafeJsonConvert
{
/// <summary>
/// Wrapper arround SafeJsonConverter.DeserializeObject to parse json return from the AspNetZero Swagger response
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="json"></param>
/// <param name="settings"></param>
/// <returns></returns>
public static T DeserializeObject<T>(string json, JsonSerializerSettings settings)
{
var a = SafeJsonConvert.DeserializeObject<Dictionary<string, object>>(json, settings);
var b = a.ToArray()[0];
var jsonResult = b.Value.ToString();
return SafeJsonConvert.DeserializeObject<T>(jsonResult, settings);
}
}
then replace each occurence of:
_result.Body = SafeJsonConvert.DeserializeObject<...
with:
_result.Body = YourProjectNameSpace.AnzSafeJsonConvert.DeserializeObject<...
hope this helps
of course, this is not plug and play so you do need to make some changes to the above code, but I am sure you all will know what to change
if anyone has found better solution, let me know
under which class I find mt-cookie-consent-bar
where is the latest source for this version?
yes
Had to add System.Net.Http version 4.3.1 to the Web.Host project to make it working
Facebook still does not return Email address so the authentication failes
google works
updating Owin to 3.1.0-rc1 still did not fix Facebook missing email address
from what I can see, eventcloud application also does not retrieve emailaddress!!!
any solution for this issue?
<cite>hikalkan: </cite> Hi,
It seems related to facebook or your app settings on the facebook. For example, it's working for our demo and for our example projects (try it: <a class="postlink" href="http://eventcloud.aspnetboilerplate.com/">http://eventcloud.aspnetboilerplate.com/</a>). Maybe there is a setting you should enable on your facebook developer page. It's better to get support from comunity or directly from facebook, since we are using Microsoft.Owin.Security.Facebook package, which is faily common. Have a nice day.